Add debug logging to automation initial state (#7068)

This commit is contained in:
Adam Mills 2017-04-16 18:45:40 -04:00 committed by Paulus Schoutsen
parent 1ce2b6357a
commit 37f959eb02

View File

@ -263,15 +263,23 @@ class AutomationEntity(ToggleEntity):
@asyncio.coroutine
def async_added_to_hass(self) -> None:
"""Startup with initial state or previous state."""
enable_automation = DEFAULT_INITIAL_STATE
if self._initial_state is not None:
enable_automation = self._initial_state
_LOGGER.debug("Automation %s initial state %s from config "
"initial_state", self.entity_id, enable_automation)
else:
state = yield from async_get_last_state(self.hass, self.entity_id)
if state:
enable_automation = state.state == STATE_ON
self._last_triggered = state.attributes.get('last_triggered')
_LOGGER.debug("Automation %s initial state %s from recorder "
"last state %s", self.entity_id,
enable_automation, state)
else:
enable_automation = DEFAULT_INITIAL_STATE
_LOGGER.debug("Automation %s initial state %s from default "
"initial state", self.entity_id,
enable_automation)
if not enable_automation:
return