Ensure SimpliSafe state sync when websocket falters (#33680)

pull/33704/head
Aaron Bach 2020-04-05 10:47:04 -06:00 committed by GitHub
parent d33cf28936
commit c8df5fb8ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -217,6 +217,20 @@ class SimpliSafeAlarm(SimpliSafeEntity, AlarmControlPanel):
}
)
# Although system state updates are designed the come via the websocket, the
# SimpliSafe cloud can sporadically fail to send those updates as expected; so,
# just in case, we synchronize the state via the REST API, too:
if self._system.state == SystemStates.away:
self._state = STATE_ALARM_ARMED_AWAY
elif self._system.state in (SystemStates.away_count, SystemStates.exit_delay):
self._state = STATE_ALARM_ARMING
elif self._system.state == SystemStates.home:
self._state = STATE_ALARM_ARMED_HOME
elif self._system.state == SystemStates.off:
self._state = STATE_ALARM_DISARMED
else:
self._state = None
@callback
def async_update_from_websocket_event(self, event):
"""Update the entity with the provided websocket API event data."""