From c8df5fb8ad7700db97c9f82e4fd4ea5b22e3a9b1 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Sun, 5 Apr 2020 10:47:04 -0600 Subject: [PATCH] Ensure SimpliSafe state sync when websocket falters (#33680) --- .../components/simplisafe/alarm_control_panel.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/homeassistant/components/simplisafe/alarm_control_panel.py b/homeassistant/components/simplisafe/alarm_control_panel.py index 4e2393bd238..a95f77ab360 100644 --- a/homeassistant/components/simplisafe/alarm_control_panel.py +++ b/homeassistant/components/simplisafe/alarm_control_panel.py @@ -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."""