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:
Adam Mills authored and Paulus Schoutsen committed 2018-11-28 13:16:43 +01:00
1 parent a039c3209b
commit 5c3a4e3d10
46 files changed
+493 -422

No files matched your search

+3 -4
View File
@@ -12,9 +12,9 @@ import voluptuous as vol
import homeassistant.util.dt as dt_util
import homeassistant.helpers.config_validation as cv
from homeassistant.const import (ATTR_ENTITY_ID, CONF_ICON, CONF_NAME)
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.event import async_track_point_in_utc_time
from homeassistant.helpers.restore_state import RestoreEntity
_LOGGER = logging.getLogger(__name__)
@@ -97,7 +97,7 @@ async def async_setup(hass, config):
return True
class Timer(Entity):
class Timer(RestoreEntity):
"""Representation of a timer."""
def __init__(self, hass, object_id, name, icon, duration):
@@ -146,8 +146,7 @@ class Timer(Entity):
if self._state is not None:
return
restore_state = self._hass.helpers.restore_state
state = await restore_state.async_get_last_state(self.entity_id)
state = await self.async_get_last_state()
self._state = state and state.state == state
async def async_start(self, duration):