Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix restore state for manual alarm control panel #19284

Merged
merged 3 commits into from Dec 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions homeassistant/components/alarm_control_panel/manual.py
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