Restore Tado binary sensor attributes (#46069)

This commit is contained in:
Álvaro Fernández Rojas 2021-02-24 14:17:01 +01:00 committed by GitHub
parent b645b151f9
commit 470121e5b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 0 deletions

View file

@ -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