Skip to content

Commit

Permalink
Fixed manual alarm control panel restore state
Browse files Browse the repository at this point in the history
  • Loading branch information
liaanvdm committed Dec 14, 2018
1 parent bb11b0f commit 61c9faf
Show file tree
Hide file tree
Showing 2 changed files with 591 additions and 2 deletions.
12 changes: 10 additions & 2 deletions homeassistant/components/alarm_control_panel/manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,15 @@ def device_state_attributes(self):

async def async_added_to_hass(self):
"""Run when entity about to be added to hass."""
await super().async_added_to_hass()
state = await self.async_get_last_state()
if state:
self._state = state.state
self._state_ts = state.last_updated
if state.state == STATE_ALARM_PENDING and \
hasattr(state, 'attributes') and \
state.attributes['pre_pending_state']:
# If in pending state, we return to the pre_pending_state
self._state = state.attributes['pre_pending_state']
self._state_ts = dt_util.utcnow()
else:
self._state = state.state
self._state_ts = state.last_updated

0 comments on commit 61c9faf

Please sign in to comment.