From b3982c1ae0dbac2fb2f5c250166f303459c6b368 Mon Sep 17 00:00:00 2001 From: Lorenzo Monaco Date: Sat, 13 Jan 2024 20:54:33 +0000 Subject: [PATCH] Fix _attr_is_on error in binary_sensor on HA 2024.1.3. --- custom_components/delios/coordinator.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/custom_components/delios/coordinator.py b/custom_components/delios/coordinator.py index bca8cb4..816f3a3 100644 --- a/custom_components/delios/coordinator.py +++ b/custom_components/delios/coordinator.py @@ -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 @@ -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