2020-12-27 15:36:35 +00:00
|
|
|
"""Base class for Tado entity."""
|
2023-08-11 02:04:26 +00:00
|
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
|
|
|
from homeassistant.helpers.entity import Entity
|
2020-04-12 18:42:36 +00:00
|
|
|
|
2021-03-10 20:31:37 +00:00
|
|
|
from .const import DEFAULT_NAME, DOMAIN, TADO_HOME, TADO_ZONE
|
2020-12-27 15:36:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TadoDeviceEntity(Entity):
|
|
|
|
"""Base implementation for Tado device."""
|
|
|
|
|
2022-08-27 02:03:50 +00:00
|
|
|
_attr_should_poll = False
|
2023-07-23 12:32:25 +00:00
|
|
|
_attr_has_entity_name = True
|
2022-08-27 02:03:50 +00:00
|
|
|
|
2020-12-27 15:36:35 +00:00
|
|
|
def __init__(self, device_info):
|
|
|
|
"""Initialize a Tado device."""
|
|
|
|
super().__init__()
|
|
|
|
self._device_info = device_info
|
2021-01-04 02:53:15 +00:00
|
|
|
self.device_name = device_info["serialNo"]
|
|
|
|
self.device_id = device_info["shortSerialNo"]
|
2023-09-07 23:15:49 +00:00
|
|
|
self._attr_device_info = DeviceInfo(
|
2022-04-26 22:16:39 +00:00
|
|
|
configuration_url=f"https://app.tado.com/en/main/settings/rooms-and-devices/device/{self.device_name}",
|
2021-10-22 10:52:33 +00:00
|
|
|
identifiers={(DOMAIN, self.device_id)},
|
|
|
|
name=self.device_name,
|
|
|
|
manufacturer=DEFAULT_NAME,
|
2023-09-07 23:15:49 +00:00
|
|
|
sw_version=device_info["currentFwVersion"],
|
|
|
|
model=device_info["deviceType"],
|
|
|
|
via_device=(DOMAIN, device_info["serialNo"]),
|
2021-10-22 10:52:33 +00:00
|
|
|
)
|
2020-12-27 15:36:35 +00:00
|
|
|
|
2020-04-12 18:42:36 +00:00
|
|
|
|
2021-03-10 20:31:37 +00:00
|
|
|
class TadoHomeEntity(Entity):
|
|
|
|
"""Base implementation for Tado home."""
|
|
|
|
|
2023-03-28 12:24:19 +00:00
|
|
|
_attr_should_poll = False
|
2023-07-23 12:32:25 +00:00
|
|
|
_attr_has_entity_name = True
|
2023-03-28 12:24:19 +00:00
|
|
|
|
2021-03-10 20:31:37 +00:00
|
|
|
def __init__(self, tado):
|
|
|
|
"""Initialize a Tado home."""
|
|
|
|
super().__init__()
|
|
|
|
self.home_name = tado.home_name
|
|
|
|
self.home_id = tado.home_id
|
2023-09-07 23:15:49 +00:00
|
|
|
self._attr_device_info = DeviceInfo(
|
2022-04-26 22:16:39 +00:00
|
|
|
configuration_url="https://app.tado.com",
|
2023-09-07 23:15:49 +00:00
|
|
|
identifiers={(DOMAIN, tado.home_id)},
|
2021-10-28 16:20:09 +00:00
|
|
|
manufacturer=DEFAULT_NAME,
|
|
|
|
model=TADO_HOME,
|
2023-09-07 23:15:49 +00:00
|
|
|
name=tado.home_name,
|
2021-10-28 16:20:09 +00:00
|
|
|
)
|
2021-03-10 20:31:37 +00:00
|
|
|
|
|
|
|
|
2020-04-12 18:42:36 +00:00
|
|
|
class TadoZoneEntity(Entity):
|
2020-12-27 15:36:35 +00:00
|
|
|
"""Base implementation for Tado zone."""
|
2020-04-12 18:42:36 +00:00
|
|
|
|
2023-07-23 12:32:25 +00:00
|
|
|
_attr_has_entity_name = True
|
2022-08-27 02:03:50 +00:00
|
|
|
_attr_should_poll = False
|
|
|
|
|
2020-12-28 13:57:51 +00:00
|
|
|
def __init__(self, zone_name, home_id, zone_id):
|
2020-12-27 15:36:35 +00:00
|
|
|
"""Initialize a Tado zone."""
|
2020-04-12 18:42:36 +00:00
|
|
|
super().__init__()
|
|
|
|
self.zone_name = zone_name
|
2021-01-02 12:35:59 +00:00
|
|
|
self.zone_id = zone_id
|
2023-09-07 23:15:49 +00:00
|
|
|
self._attr_device_info = DeviceInfo(
|
|
|
|
configuration_url=(f"https://app.tado.com/en/main/home/zoneV2/{zone_id}"),
|
|
|
|
identifiers={(DOMAIN, f"{home_id}_{zone_id}")},
|
|
|
|
name=zone_name,
|
2021-10-23 10:03:14 +00:00
|
|
|
manufacturer=DEFAULT_NAME,
|
|
|
|
model=TADO_ZONE,
|
2023-09-07 23:15:49 +00:00
|
|
|
suggested_area=zone_name,
|
2021-10-23 10:03:14 +00:00
|
|
|
)
|