From bb32df50d37a0981f5b85bd7c6cfc9de10880451 Mon Sep 17 00:00:00 2001 From: cyrilp Date: Mon, 18 Mar 2024 20:45:17 +0100 Subject: [PATCH] fix alarm state --- .../deltadore_tydom/ha_entities.py | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/custom_components/deltadore_tydom/ha_entities.py b/custom_components/deltadore_tydom/ha_entities.py index 8417e78..33bbdb1 100644 --- a/custom_components/deltadore_tydom/ha_entities.py +++ b/custom_components/deltadore_tydom/ha_entities.py @@ -895,7 +895,7 @@ async def async_turn_off(self, **kwargs): class HaAlarm(AlarmControlPanelEntity, HAEntity): """Representation of an Alarm.""" - should_poll = True + should_poll = False supported_features = 0 sensor_classes = { "networkDefect": BinarySensorDeviceClass.PROBLEM, @@ -949,15 +949,21 @@ def state(self) -> str | None: if self._device.alarmMode == "MAINTENANCE": return STATE_ALARM_DISARMED - match self._device.alarmState: + match self._device.alarmMode: + case "MAINTENANCE": + return STATE_ALARM_DISARMED case "OFF": return STATE_ALARM_DISARMED case "ON": - match self._device.alarmMode: - case "ON": - return STATE_ALARM_ARMED_AWAY - case "ZONE" | "PART": - return STATE_ALARM_ARMED_HOME + if self._device.alarmState == "OFF": + return STATE_ALARM_ARMED_AWAY + else: + return STATE_ALARM_TRIGGERED + case "ZONE" | "PART": + if self._device.alarmState == "OFF": + return STATE_ALARM_ARMED_HOME + else: + return STATE_ALARM_TRIGGERED case _: return STATE_ALARM_TRIGGERED