Restore Tado binary sensor attributes (#46069)
parent
b645b151f9
commit
470121e5b0
|
@ -183,6 +183,7 @@ class TadoZoneBinarySensor(TadoZoneEntity, BinarySensorEntity):
|
|||
self._unique_id = f"{zone_variable} {zone_id} {tado.home_id}"
|
||||
|
||||
self._state = None
|
||||
self._state_attributes = None
|
||||
self._tado_zone_data = None
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
|
@ -229,6 +230,11 @@ class TadoZoneBinarySensor(TadoZoneEntity, BinarySensorEntity):
|
|||
return DEVICE_CLASS_POWER
|
||||
return None
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
return self._state_attributes
|
||||
|
||||
@callback
|
||||
def _async_update_callback(self):
|
||||
"""Update and write state."""
|
||||
|
@ -251,6 +257,10 @@ class TadoZoneBinarySensor(TadoZoneEntity, BinarySensorEntity):
|
|||
|
||||
elif self.zone_variable == "overlay":
|
||||
self._state = self._tado_zone_data.overlay_active
|
||||
if self._tado_zone_data.overlay_active:
|
||||
self._state_attributes = {
|
||||
"termination": self._tado_zone_data.overlay_termination_type
|
||||
}
|
||||
|
||||
elif self.zone_variable == "early start":
|
||||
self._state = self._tado_zone_data.preparation
|
||||
|
@ -260,3 +270,4 @@ class TadoZoneBinarySensor(TadoZoneEntity, BinarySensorEntity):
|
|||
self._tado_zone_data.open_window
|
||||
or self._tado_zone_data.open_window_detected
|
||||
)
|
||||
self._state_attributes = self._tado_zone_data.open_window_attr
|
||||
|
|
|
@ -46,6 +46,9 @@ async def async_init_integration(
|
|||
# Device Temp Offset
|
||||
device_temp_offset = "tado/device_temp_offset.json"
|
||||
|
||||
# Zone Default Overlay
|
||||
zone_def_overlay = "tado/zone_default_overlay.json"
|
||||
|
||||
with requests_mock.mock() as m:
|
||||
m.post("https://auth.tado.com/oauth/token", text=load_fixture(token_fixture))
|
||||
m.get(
|
||||
|
@ -92,6 +95,26 @@ async def async_init_integration(
|
|||
"https://my.tado.com/api/v2/homes/1/zones/1/capabilities",
|
||||
text=load_fixture(zone_1_capabilities_fixture),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/1/defaultOverlay",
|
||||
text=load_fixture(zone_def_overlay),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/2/defaultOverlay",
|
||||
text=load_fixture(zone_def_overlay),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/3/defaultOverlay",
|
||||
text=load_fixture(zone_def_overlay),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/4/defaultOverlay",
|
||||
text=load_fixture(zone_def_overlay),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/5/defaultOverlay",
|
||||
text=load_fixture(zone_def_overlay),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/5/state",
|
||||
text=load_fixture(zone_5_state_fixture),
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"terminationCondition": {
|
||||
"type": "MANUAL"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue