Fix uneeded state update in Idasen Desk sensor (#111433)

This commit is contained in:
Abílio Costa 2024-02-26 01:03:52 +00:00 committed by GitHub
parent bfd82a0780
commit 5a8779551b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -91,10 +91,14 @@ class IdasenDeskSensor(CoordinatorEntity[IdasenDeskCoordinator], SensorEntity):
async def async_added_to_hass(self) -> None:
"""When entity is added to hass."""
await super().async_added_to_hass()
self._handle_coordinator_update()
self._update_native_value()
@callback
def _handle_coordinator_update(self, *args: Any) -> None:
"""Handle data update."""
self._attr_native_value = self.entity_description.value_fn(self.coordinator)
self._update_native_value()
super()._handle_coordinator_update()
def _update_native_value(self) -> None:
"""Update the native value attribute."""
self._attr_native_value = self.entity_description.value_fn(self.coordinator)