Skip to content

Commit

Permalink
Add connection lost and restored events
Browse files Browse the repository at this point in the history
  • Loading branch information
bachya committed Feb 5, 2020
1 parent 1d89126 commit e7ffe05
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
13 changes: 6 additions & 7 deletions homeassistant/components/simplisafe/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
EVENT_ARMED_HOME,
EVENT_AWAY_EXIT_DELAY_BY_KEYPAD,
EVENT_AWAY_EXIT_DELAY_BY_REMOTE,
EVENT_CONNECTION_LOST,
EVENT_CONNECTION_RESTORED,
EVENT_DISARMED_BY_MASTER_PIN,
EVENT_DISARMED_BY_REMOTE,
EVENT_HOME_EXIT_DELAY,
Expand Down Expand Up @@ -175,11 +177,6 @@ async def async_alarm_arm_away(self, code=None):
@callback
def async_update_from_rest_api(self):
"""Update the entity with the provided REST API data."""
if self._system.state == SystemStates.error:
self._online = False
return
self._online = True

if self._system.version == 3:
self._attrs.update(
{
Expand Down Expand Up @@ -227,7 +224,9 @@ def async_update_from_websocket_event(self, event):
EVENT_HOME_EXIT_DELAY,
):
self._state = STATE_ALARM_ARMING
else:
self._state = None
elif event.event_type == EVENT_CONNECTION_LOST:
self._online = False
elif event.event_type == EVENT_CONNECTION_RESTORED:
self._online = True

self._changed_by = event.changed_by
14 changes: 11 additions & 3 deletions homeassistant/components/simplisafe/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@

from simplipy.errors import SimplipyError
from simplipy.lock import LockStates
from simplipy.websocket import EVENT_LOCK_ERROR, EVENT_LOCK_LOCKED, EVENT_LOCK_UNLOCKED
from simplipy.websocket import (
EVENT_CONNECTION_LOST,
EVENT_CONNECTION_RESTORED,
EVENT_LOCK_ERROR,
EVENT_LOCK_LOCKED,
EVENT_LOCK_UNLOCKED,
)

from homeassistant.components.lock import LockDevice
from homeassistant.const import STATE_LOCKED, STATE_UNKNOWN, STATE_UNLOCKED
Expand Down Expand Up @@ -89,5 +95,7 @@ def async_update_from_websocket_event(self, event):
self._state = STATE_UNLOCKED
elif event.event_type == EVENT_LOCK_ERROR:
self._state = STATE_UNKNOWN
else:
self._state = None
elif event.event_type == EVENT_CONNECTION_LOST:
self._online = False
elif event.event_type == EVENT_CONNECTION_RESTORED:
self._online = True
2 changes: 1 addition & 1 deletion homeassistant/components/simplisafe/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "SimpliSafe",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/simplisafe",
"requirements": ["simplisafe-python==7.1.0"],
"requirements": ["simplisafe-python==7.2.0"],
"dependencies": [],
"codeowners": ["@bachya"]
}
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,7 @@ simplehound==0.3
simplepush==1.1.4

# homeassistant.components.simplisafe
simplisafe-python==7.1.0
simplisafe-python==7.2.0

# homeassistant.components.sisyphus
sisyphus-control==2.2.1
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ sentry-sdk==0.13.5
simplehound==0.3

# homeassistant.components.simplisafe
simplisafe-python==7.1.0
simplisafe-python==7.2.0

# homeassistant.components.sleepiq
sleepyq==0.7
Expand Down

0 comments on commit e7ffe05

Please sign in to comment.