Streamline Notion CoordinatorEntity (#43027)

This commit is contained in:
Aaron Bach 2020-11-10 01:24:27 -07:00 committed by GitHub
parent 244bfb2096
commit 49b4f9d2c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -246,15 +246,13 @@ class NotionEntity(CoordinatorEntity):
"""Update the entity from the latest data.""" """Update the entity from the latest data."""
raise NotImplementedError raise NotImplementedError
async def async_added_to_hass(self) -> None: @callback
"""Register callbacks.""" def _handle_coordinator_update(self):
"""Respond to a DataUpdateCoordinator update."""
@callback self._async_update_from_latest_data()
def update(): self.async_write_ha_state()
"""Update the state."""
self._async_update_from_latest_data() async def async_added_to_hass(self):
self.async_write_ha_state() """Handle entity which will be added."""
await super().async_added_to_hass()
self.async_on_remove(self.coordinator.async_add_listener(update))
self._async_update_from_latest_data() self._async_update_from_latest_data()