Skip to content

Commit

Permalink
Fix _attr_is_on error in binary_sensor on HA 2024.1.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
lnx85 committed Jan 13, 2024
1 parent 2b49d16 commit b3982c1
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions custom_components/delios/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def __init__(

super().__init__(coordinator, context=attribute)
self._attribute = attribute
self._internal_value = None
inverter = self.coordinator.inverter
self.entity_id = ENTITY_ID_BINARY_SENSOR_FORMAT.format(
slugify(inverter.name), attribute.key
Expand All @@ -60,20 +59,14 @@ def __init__(
model=inverter.model,
)
if self.coordinator.data:
self._internal_value = self._attribute.value(self.coordinator.data)

@property
def _attr_is_on(self) -> bool:
"""Return value of sensor."""

return self._internal_value
self._attr_is_on = self._attribute.value(self.coordinator.data)

@callback
def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator."""

try:
self._internal_value = self._attribute.value(self.coordinator.data)
self._attr_is_on = self._attribute.value(self.coordinator.data)
self.async_write_ha_state()
except KeyError:
pass
Expand Down

0 comments on commit b3982c1

Please sign in to comment.