mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix restore state for manual alarm control panel (#19284)
* Fixed manual alarm control panel restore state * Revert "Fixed manual alarm control panel restore state" This reverts commit 61c9faf434a8bb276133578a0811100a796784ca. * Fixed manual alarm control panel's state restore
This commit is contained in:
parent
a30921e67d
commit
027920ff52
@ -310,7 +310,15 @@ class ManualAlarm(alarm.AlarmControlPanel, RestoreEntity):
|
||||
|
||||
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:
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user