mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Streamline Notion CoordinatorEntity (#43027)
This commit is contained in:
parent
244bfb2096
commit
49b4f9d2c6
@ -246,15 +246,13 @@ class NotionEntity(CoordinatorEntity):
|
||||
"""Update the entity from the latest data."""
|
||||
raise NotImplementedError
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
|
||||
@callback
|
||||
def update():
|
||||
"""Update the state."""
|
||||
self._async_update_from_latest_data()
|
||||
self.async_write_ha_state()
|
||||
|
||||
self.async_on_remove(self.coordinator.async_add_listener(update))
|
||||
|
||||
@callback
|
||||
def _handle_coordinator_update(self):
|
||||
"""Respond to a DataUpdateCoordinator update."""
|
||||
self._async_update_from_latest_data()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Handle entity which will be added."""
|
||||
await super().async_added_to_hass()
|
||||
self._async_update_from_latest_data()
|
||||
|
Loading…
x
Reference in New Issue
Block a user