2020-12-27 15:36:35 +00:00
|
|
|
"""Base class for Tado entity."""
|
2020-04-12 18:42:36 +00:00
|
|
|
from homeassistant.helpers.entity import Entity
|
|
|
|
|
2020-12-27 15:36:35 +00:00
|
|
|
from .const import DEFAULT_NAME, DOMAIN, 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
|
2021-01-04 02:53:15 +00:00
|
|
|
self.device_name = device_info["serialNo"]
|
|
|
|
self.device_id = device_info["shortSerialNo"]
|
2020-12-27 15:36:35 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def device_info(self):
|
|
|
|
"""Return the device_info of the device."""
|
|
|
|
return {
|
|
|
|
"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
|
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
|
|
|
|
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__()
|
2020-12-28 13:57:51 +00:00
|
|
|
self._device_zone_id = f"{home_id}_{zone_id}"
|
2020-04-12 18:42:36 +00:00
|
|
|
self.zone_name = zone_name
|
2021-01-02 12:35:59 +00:00
|
|
|
self.zone_id = zone_id
|
2020-04-12 18:42:36 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def device_info(self):
|
|
|
|
"""Return the device_info of the device."""
|
|
|
|
return {
|
|
|
|
"identifiers": {(DOMAIN, self._device_zone_id)},
|
|
|
|
"name": self.zone_name,
|
|
|
|
"manufacturer": DEFAULT_NAME,
|
2020-12-27 15:36:35 +00:00
|
|
|
"model": TADO_ZONE,
|
2020-04-12 18:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@property
|
|
|
|
def should_poll(self):
|
|
|
|
"""Do not poll."""
|
|
|
|
return False
|