mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Fix missing triggered state in SimpliSafe alarm control panel (#58628)
This commit is contained in:
parent
e32fdfec84
commit
0f25900309
@ -151,22 +151,7 @@ class SimpliSafeAlarm(SimpliSafeEntity, AlarmControlPanelEntity):
|
|||||||
self._attr_supported_features = SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY
|
self._attr_supported_features = SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY
|
||||||
self._last_event = None
|
self._last_event = None
|
||||||
|
|
||||||
if system.alarm_going_off:
|
self._set_state_from_system_data()
|
||||||
self._attr_state = STATE_ALARM_TRIGGERED
|
|
||||||
elif system.state == SystemStates.away:
|
|
||||||
self._attr_state = STATE_ALARM_ARMED_AWAY
|
|
||||||
elif system.state in (
|
|
||||||
SystemStates.away_count,
|
|
||||||
SystemStates.exit_delay,
|
|
||||||
SystemStates.home_count,
|
|
||||||
):
|
|
||||||
self._attr_state = STATE_ALARM_ARMING
|
|
||||||
elif system.state == SystemStates.home:
|
|
||||||
self._attr_state = STATE_ALARM_ARMED_HOME
|
|
||||||
elif system.state == SystemStates.off:
|
|
||||||
self._attr_state = STATE_ALARM_DISARMED
|
|
||||||
else:
|
|
||||||
self._attr_state = None
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _is_code_valid(self, code: str | None, state: str) -> bool:
|
def _is_code_valid(self, code: str | None, state: str) -> bool:
|
||||||
@ -182,6 +167,17 @@ class SimpliSafeAlarm(SimpliSafeEntity, AlarmControlPanelEntity):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@callback
|
||||||
|
def _set_state_from_system_data(self) -> None:
|
||||||
|
"""Set the state based on the latest REST API data."""
|
||||||
|
if self._system.alarm_going_off:
|
||||||
|
self._attr_state = STATE_ALARM_TRIGGERED
|
||||||
|
elif state := STATE_MAP_FROM_REST_API.get(self._system.state):
|
||||||
|
self._attr_state = state
|
||||||
|
else:
|
||||||
|
LOGGER.error("Unknown system state (REST API): %s", self._system.state)
|
||||||
|
self._attr_state = None
|
||||||
|
|
||||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||||
"""Send disarm command."""
|
"""Send disarm command."""
|
||||||
if not self._is_code_valid(code, STATE_ALARM_DISARMED):
|
if not self._is_code_valid(code, STATE_ALARM_DISARMED):
|
||||||
@ -266,11 +262,7 @@ class SimpliSafeAlarm(SimpliSafeEntity, AlarmControlPanelEntity):
|
|||||||
|
|
||||||
self._errors = 0
|
self._errors = 0
|
||||||
|
|
||||||
if state := STATE_MAP_FROM_REST_API.get(self._system.state):
|
self._set_state_from_system_data()
|
||||||
self._attr_state = state
|
|
||||||
else:
|
|
||||||
LOGGER.error("Unknown system state (REST API): %s", self._system.state)
|
|
||||||
self._attr_state = None
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_update_from_websocket_event(self, event: WebsocketEvent) -> None:
|
def async_update_from_websocket_event(self, event: WebsocketEvent) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user