Restore states through a JSON store instead of recorder (#17270)
* Restore states through a JSON store * Accept entity_id directly in restore state helper * Keep states stored between runs for a limited time * Remove warning
This commit is contained in:
parent
a039c3209b
commit
5c3a4e3d10
46 changed files with 493 additions and 422 deletions
|
@ -363,10 +363,7 @@ class Entity:
|
|||
|
||||
async def async_remove(self):
|
||||
"""Remove entity from Home Assistant."""
|
||||
will_remove = getattr(self, 'async_will_remove_from_hass', None)
|
||||
|
||||
if will_remove:
|
||||
await will_remove() # pylint: disable=not-callable
|
||||
await self.async_will_remove_from_hass()
|
||||
|
||||
if self._on_remove is not None:
|
||||
while self._on_remove:
|
||||
|
@ -390,6 +387,12 @@ class Entity:
|
|||
|
||||
self.hass.async_create_task(readd())
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Run when entity about to be added to hass."""
|
||||
|
||||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Run when entity will be removed from hass."""
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Return the comparison."""
|
||||
if not isinstance(other, self.__class__):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue