From 49b4f9d2c6963fa01d05aa660e579c5f5fc63d85 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Tue, 10 Nov 2020 01:24:27 -0700 Subject: [PATCH] Streamline Notion CoordinatorEntity (#43027) --- homeassistant/components/notion/__init__.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/notion/__init__.py b/homeassistant/components/notion/__init__.py index ebc3010308e..c17b68a55b1 100644 --- a/homeassistant/components/notion/__init__.py +++ b/homeassistant/components/notion/__init__.py @@ -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()