mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add additional alarm states to SimpliSafe (#31060)
* Add additional alarm states to SimpliSafe * Remove unused constant * Remove redundant local variable
This commit is contained in:
parent
d3511a3496
commit
37d1cdc4cb
@ -19,7 +19,9 @@ from homeassistant.const import (
|
||||
CONF_CODE,
|
||||
STATE_ALARM_ARMED_AWAY,
|
||||
STATE_ALARM_ARMED_HOME,
|
||||
STATE_ALARM_ARMING,
|
||||
STATE_ALARM_DISARMED,
|
||||
STATE_ALARM_TRIGGERED,
|
||||
)
|
||||
from homeassistant.util.dt import utc_from_timestamp
|
||||
|
||||
@ -28,7 +30,6 @@ from .const import DATA_CLIENT, DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ATTR_ALARM_ACTIVE = "alarm_active"
|
||||
ATTR_ALARM_DURATION = "alarm_duration"
|
||||
ATTR_ALARM_VOLUME = "alarm_volume"
|
||||
ATTR_BATTERY_BACKUP_POWER_LEVEL = "battery_backup_power_level"
|
||||
@ -80,7 +81,6 @@ class SimpliSafeAlarm(SimpliSafeEntity, AlarmControlPanel):
|
||||
self._simplisafe = simplisafe
|
||||
self._state = None
|
||||
|
||||
self._attrs.update({ATTR_ALARM_ACTIVE: self._system.alarm_going_off})
|
||||
if self._system.version == 3:
|
||||
self._attrs.update(
|
||||
{
|
||||
@ -157,10 +157,10 @@ class SimpliSafeAlarm(SimpliSafeEntity, AlarmControlPanel):
|
||||
|
||||
async def async_update(self):
|
||||
"""Update alarm status."""
|
||||
event_data = self._simplisafe.last_event_data[self._system.system_id]
|
||||
last_event = self._simplisafe.last_event_data[self._system.system_id]
|
||||
|
||||
if event_data.get("pinName"):
|
||||
self._changed_by = event_data["pinName"]
|
||||
if last_event.get("pinName"):
|
||||
self._changed_by = last_event["pinName"]
|
||||
|
||||
if self._system.state == SystemStates.error:
|
||||
self._online = False
|
||||
@ -168,21 +168,23 @@ class SimpliSafeAlarm(SimpliSafeEntity, AlarmControlPanel):
|
||||
|
||||
self._online = True
|
||||
|
||||
if self._system.state == SystemStates.off:
|
||||
self._state = STATE_ALARM_DISARMED
|
||||
elif self._system.state in (SystemStates.home, SystemStates.home_count):
|
||||
self._state = STATE_ALARM_ARMED_HOME
|
||||
if self._system.alarm_going_off:
|
||||
self._state = STATE_ALARM_TRIGGERED
|
||||
elif self._system.state == SystemStates.away:
|
||||
self._state = STATE_ALARM_ARMED_AWAY
|
||||
elif self._system.state in (
|
||||
SystemStates.away,
|
||||
SystemStates.away_count,
|
||||
SystemStates.exit_delay,
|
||||
SystemStates.home_count,
|
||||
):
|
||||
self._state = STATE_ALARM_ARMED_AWAY
|
||||
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
|
||||
|
||||
last_event = self._simplisafe.last_event_data[self._system.system_id]
|
||||
|
||||
try:
|
||||
last_event_sensor_type = EntityTypes(last_event["sensorType"]).name
|
||||
except ValueError:
|
||||
|
Loading…
x
Reference in New Issue
Block a user