mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Better restore_state warnings (#6418)
This commit is contained in:
parent
10bf659773
commit
7655b6271d
@ -54,10 +54,12 @@ def async_get_last_state(hass, entity_id: str):
|
|||||||
if DATA_RESTORE_CACHE in hass.data:
|
if DATA_RESTORE_CACHE in hass.data:
|
||||||
return hass.data[DATA_RESTORE_CACHE].get(entity_id)
|
return hass.data[DATA_RESTORE_CACHE].get(entity_id)
|
||||||
|
|
||||||
if (_RECORDER not in hass.config.components or
|
if _RECORDER not in hass.config.components:
|
||||||
hass.state not in (CoreState.starting, CoreState.not_running)):
|
return None
|
||||||
_LOGGER.error("Cache can only be loaded during startup, not %s",
|
|
||||||
hass.state)
|
if hass.state not in (CoreState.starting, CoreState.not_running):
|
||||||
|
_LOGGER.debug("Cache for %s can only be loaded during startup, not %s",
|
||||||
|
entity_id, hass.state)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -83,9 +85,9 @@ def async_get_last_state(hass, entity_id: str):
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_restore_state(entity, extract_info):
|
def async_restore_state(entity, extract_info):
|
||||||
"""Helper to call entity.async_restore_state with cached info."""
|
"""Helper to call entity.async_restore_state with cached info."""
|
||||||
if entity.hass.state != CoreState.starting:
|
if entity.hass.state not in (CoreState.starting, CoreState.not_running):
|
||||||
_LOGGER.debug("Not restoring state: State is not starting: %s",
|
_LOGGER.debug("Not restoring state for %s: Hass is not starting: %s",
|
||||||
entity.hass.state)
|
entity.entity_id, entity.hass.state)
|
||||||
return
|
return
|
||||||
|
|
||||||
state = yield from async_get_last_state(entity.hass, entity.entity_id)
|
state = yield from async_get_last_state(entity.hass, entity.entity_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user