Add connection lost and restored events
This commit is contained in:
parent
1d89126944
commit
e7ffe05938
5 changed files with 20 additions and 13 deletions
|
@ -13,6 +13,8 @@ from simplipy.websocket import (
|
||||||
EVENT_ARMED_HOME,
|
EVENT_ARMED_HOME,
|
||||||
EVENT_AWAY_EXIT_DELAY_BY_KEYPAD,
|
EVENT_AWAY_EXIT_DELAY_BY_KEYPAD,
|
||||||
EVENT_AWAY_EXIT_DELAY_BY_REMOTE,
|
EVENT_AWAY_EXIT_DELAY_BY_REMOTE,
|
||||||
|
EVENT_CONNECTION_LOST,
|
||||||
|
EVENT_CONNECTION_RESTORED,
|
||||||
EVENT_DISARMED_BY_MASTER_PIN,
|
EVENT_DISARMED_BY_MASTER_PIN,
|
||||||
EVENT_DISARMED_BY_REMOTE,
|
EVENT_DISARMED_BY_REMOTE,
|
||||||
EVENT_HOME_EXIT_DELAY,
|
EVENT_HOME_EXIT_DELAY,
|
||||||
|
@ -175,11 +177,6 @@ class SimpliSafeAlarm(SimpliSafeEntity, AlarmControlPanel):
|
||||||
@callback
|
@callback
|
||||||
def async_update_from_rest_api(self):
|
def async_update_from_rest_api(self):
|
||||||
"""Update the entity with the provided REST API data."""
|
"""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:
|
if self._system.version == 3:
|
||||||
self._attrs.update(
|
self._attrs.update(
|
||||||
{
|
{
|
||||||
|
@ -227,7 +224,9 @@ class SimpliSafeAlarm(SimpliSafeEntity, AlarmControlPanel):
|
||||||
EVENT_HOME_EXIT_DELAY,
|
EVENT_HOME_EXIT_DELAY,
|
||||||
):
|
):
|
||||||
self._state = STATE_ALARM_ARMING
|
self._state = STATE_ALARM_ARMING
|
||||||
else:
|
elif event.event_type == EVENT_CONNECTION_LOST:
|
||||||
self._state = None
|
self._online = False
|
||||||
|
elif event.event_type == EVENT_CONNECTION_RESTORED:
|
||||||
|
self._online = True
|
||||||
|
|
||||||
self._changed_by = event.changed_by
|
self._changed_by = event.changed_by
|
||||||
|
|
|
@ -3,7 +3,13 @@ import logging
|
||||||
|
|
||||||
from simplipy.errors import SimplipyError
|
from simplipy.errors import SimplipyError
|
||||||
from simplipy.lock import LockStates
|
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.components.lock import LockDevice
|
||||||
from homeassistant.const import STATE_LOCKED, STATE_UNKNOWN, STATE_UNLOCKED
|
from homeassistant.const import STATE_LOCKED, STATE_UNKNOWN, STATE_UNLOCKED
|
||||||
|
@ -89,5 +95,7 @@ class SimpliSafeLock(SimpliSafeEntity, LockDevice):
|
||||||
self._state = STATE_UNLOCKED
|
self._state = STATE_UNLOCKED
|
||||||
elif event.event_type == EVENT_LOCK_ERROR:
|
elif event.event_type == EVENT_LOCK_ERROR:
|
||||||
self._state = STATE_UNKNOWN
|
self._state = STATE_UNKNOWN
|
||||||
else:
|
elif event.event_type == EVENT_CONNECTION_LOST:
|
||||||
self._state = None
|
self._online = False
|
||||||
|
elif event.event_type == EVENT_CONNECTION_RESTORED:
|
||||||
|
self._online = True
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"name": "SimpliSafe",
|
"name": "SimpliSafe",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/simplisafe",
|
"documentation": "https://www.home-assistant.io/integrations/simplisafe",
|
||||||
"requirements": ["simplisafe-python==7.1.0"],
|
"requirements": ["simplisafe-python==7.2.0"],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": ["@bachya"]
|
"codeowners": ["@bachya"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1822,7 +1822,7 @@ simplehound==0.3
|
||||||
simplepush==1.1.4
|
simplepush==1.1.4
|
||||||
|
|
||||||
# homeassistant.components.simplisafe
|
# homeassistant.components.simplisafe
|
||||||
simplisafe-python==7.1.0
|
simplisafe-python==7.2.0
|
||||||
|
|
||||||
# homeassistant.components.sisyphus
|
# homeassistant.components.sisyphus
|
||||||
sisyphus-control==2.2.1
|
sisyphus-control==2.2.1
|
||||||
|
|
|
@ -600,7 +600,7 @@ sentry-sdk==0.13.5
|
||||||
simplehound==0.3
|
simplehound==0.3
|
||||||
|
|
||||||
# homeassistant.components.simplisafe
|
# homeassistant.components.simplisafe
|
||||||
simplisafe-python==7.1.0
|
simplisafe-python==7.2.0
|
||||||
|
|
||||||
# homeassistant.components.sleepiq
|
# homeassistant.components.sleepiq
|
||||||
sleepyq==0.7
|
sleepyq==0.7
|
||||||
|
|
Loading…
Add table
Reference in a new issue