From bdfdeb2bc009d1edac77048adc7a3e31836cf1a8 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Tue, 26 Sep 2023 20:02:00 +0200 Subject: [PATCH] Call async added to hass super in Risco (#100444) --- homeassistant/components/risco/entity.py | 9 +-------- homeassistant/components/risco/sensor.py | 7 ++----- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/risco/entity.py b/homeassistant/components/risco/entity.py index f8869d75d4b..e522c29ce19 100644 --- a/homeassistant/components/risco/entity.py +++ b/homeassistant/components/risco/entity.py @@ -31,17 +31,10 @@ class RiscoCloudEntity(CoordinatorEntity[RiscoDataUpdateCoordinator]): def _get_data_from_coordinator(self) -> None: raise NotImplementedError - def _refresh_from_coordinator(self) -> None: + def _handle_coordinator_update(self) -> None: self._get_data_from_coordinator() self.async_write_ha_state() - # pylint: disable-next=hass-missing-super-call - async def async_added_to_hass(self) -> None: - """When entity is added to hass.""" - self.async_on_remove( - self.coordinator.async_add_listener(self._refresh_from_coordinator) - ) - @property def _risco(self): """Return the Risco API object.""" diff --git a/homeassistant/components/risco/sensor.py b/homeassistant/components/risco/sensor.py index b196723afbe..1d60ea4d7c2 100644 --- a/homeassistant/components/risco/sensor.py +++ b/homeassistant/components/risco/sensor.py @@ -86,15 +86,12 @@ class RiscoSensor(CoordinatorEntity[RiscoEventsDataUpdateCoordinator], SensorEnt self._attr_name = f"Risco {self.coordinator.risco.site_name} {name} Events" self._attr_device_class = SensorDeviceClass.TIMESTAMP - # pylint: disable-next=hass-missing-super-call async def async_added_to_hass(self) -> None: """When entity is added to hass.""" + await super().async_added_to_hass() self._entity_registry = er.async_get(self.hass) - self.async_on_remove( - self.coordinator.async_add_listener(self._refresh_from_coordinator) - ) - def _refresh_from_coordinator(self): + def _handle_coordinator_update(self): events = self.coordinator.data for event in reversed(events): if event.category_id in self._excludes: