From 518e462e9a0b9fd1eb9f1799401f9b4e61457cb1 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Tue, 10 Nov 2020 18:00:19 -0700 Subject: [PATCH] Streamline Tile CoordinatorEntity (#43065) --- homeassistant/components/tile/__init__.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/tile/__init__.py b/homeassistant/components/tile/__init__.py index ad4a8886873..6b43761956e 100644 --- a/homeassistant/components/tile/__init__.py +++ b/homeassistant/components/tile/__init__.py @@ -118,20 +118,18 @@ class TileEntity(CoordinatorEntity): """Return the unique ID of the entity.""" return self._unique_id + @callback + def _handle_coordinator_update(self): + """Respond to a DataUpdateCoordinator update.""" + self._update_from_latest_data() + self.async_write_ha_state() + @callback def _update_from_latest_data(self): """Update the entity from the latest data.""" raise NotImplementedError async def async_added_to_hass(self): - """Register callbacks.""" - - @callback - def update(): - """Update the state.""" - self._update_from_latest_data() - self.async_write_ha_state() - - self.async_on_remove(self.coordinator.async_add_listener(update)) - + """Handle entity which will be added.""" + await super().async_added_to_hass() self._update_from_latest_data()