-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentity.py
82 lines (67 loc) · 2.52 KB
/
entity.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"""Base class for Tado entity."""
from homeassistant.helpers.entity import DeviceInfo, Entity
from .const import DEFAULT_NAME, DOMAIN, TADO_HOME, TADO_ZONE
class TadoDeviceEntity(Entity):
"""Base implementation for Tado device."""
def __init__(self, device_info):
"""Initialize a Tado device."""
super().__init__()
self._device_info = device_info
self.device_name = device_info["serialNo"]
self.device_id = device_info["shortSerialNo"]
@property
def device_info(self) -> DeviceInfo:
"""Return the device_info of the device."""
return DeviceInfo(
configuration_url=f"https://app.tado.com/en/main/settings/rooms-and-devices/device/{self.device_name}",
identifiers={(DOMAIN, self.device_id)},
name=self.device_name,
manufacturer=DEFAULT_NAME,
sw_version=self._device_info["currentFwVersion"],
model=self._device_info["deviceType"],
via_device=(DOMAIN, self._device_info["serialNo"]),
)
@property
def should_poll(self):
"""Do not poll."""
return False
class TadoHomeEntity(Entity):
"""Base implementation for Tado home."""
def __init__(self, tado):
"""Initialize a Tado home."""
super().__init__()
self.home_name = tado.home_name
self.home_id = tado.home_id
@property
def device_info(self) -> DeviceInfo:
"""Return the device_info of the device."""
return DeviceInfo(
configuration_url="https://app.tado.com",
identifiers={(DOMAIN, self.home_id)},
manufacturer=DEFAULT_NAME,
model=TADO_HOME,
name=self.home_name,
)
class TadoZoneEntity(Entity):
"""Base implementation for Tado zone."""
def __init__(self, zone_name, home_id, zone_id):
"""Initialize a Tado zone."""
super().__init__()
self._device_zone_id = f"{home_id}_{zone_id}"
self.zone_name = zone_name
self.zone_id = zone_id
@property
def device_info(self) -> DeviceInfo:
"""Return the device_info of the device."""
return DeviceInfo(
configuration_url=f"https://app.tado.com/en/main/home/zoneV2/{self.zone_id}",
identifiers={(DOMAIN, self._device_zone_id)},
name=self.zone_name,
manufacturer=DEFAULT_NAME,
model=TADO_ZONE,
suggested_area=self.zone_name,
)
@property
def should_poll(self):
"""Do not poll."""
return False