mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Streamline Tile CoordinatorEntity (#43065)
This commit is contained in:
parent
9b58b24b17
commit
518e462e9a
@ -118,20 +118,18 @@ class TileEntity(CoordinatorEntity):
|
|||||||
"""Return the unique ID of the entity."""
|
"""Return the unique ID of the entity."""
|
||||||
return self._unique_id
|
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
|
@callback
|
||||||
def _update_from_latest_data(self):
|
def _update_from_latest_data(self):
|
||||||
"""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):
|
async def async_added_to_hass(self):
|
||||||
"""Register callbacks."""
|
"""Handle entity which will be added."""
|
||||||
|
await super().async_added_to_hass()
|
||||||
@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))
|
|
||||||
|
|
||||||
self._update_from_latest_data()
|
self._update_from_latest_data()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user