Call async added to hass super in Risco (#100444)
This commit is contained in:
parent
ae7ede1253
commit
bdfdeb2bc0
2 changed files with 3 additions and 13 deletions
|
@ -31,17 +31,10 @@ class RiscoCloudEntity(CoordinatorEntity[RiscoDataUpdateCoordinator]):
|
||||||
def _get_data_from_coordinator(self) -> None:
|
def _get_data_from_coordinator(self) -> None:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def _refresh_from_coordinator(self) -> None:
|
def _handle_coordinator_update(self) -> None:
|
||||||
self._get_data_from_coordinator()
|
self._get_data_from_coordinator()
|
||||||
self.async_write_ha_state()
|
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
|
@property
|
||||||
def _risco(self):
|
def _risco(self):
|
||||||
"""Return the Risco API object."""
|
"""Return the Risco API object."""
|
||||||
|
|
|
@ -86,15 +86,12 @@ class RiscoSensor(CoordinatorEntity[RiscoEventsDataUpdateCoordinator], SensorEnt
|
||||||
self._attr_name = f"Risco {self.coordinator.risco.site_name} {name} Events"
|
self._attr_name = f"Risco {self.coordinator.risco.site_name} {name} Events"
|
||||||
self._attr_device_class = SensorDeviceClass.TIMESTAMP
|
self._attr_device_class = SensorDeviceClass.TIMESTAMP
|
||||||
|
|
||||||
# pylint: disable-next=hass-missing-super-call
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
"""When entity is added to hass."""
|
"""When entity is added to hass."""
|
||||||
|
await super().async_added_to_hass()
|
||||||
self._entity_registry = er.async_get(self.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
|
events = self.coordinator.data
|
||||||
for event in reversed(events):
|
for event in reversed(events):
|
||||||
if event.category_id in self._excludes:
|
if event.category_id in self._excludes:
|
||||||
|
|
Loading…
Add table
Reference in a new issue