From fb11c2a103d2a807d02ad653282f0cdc7d26529f Mon Sep 17 00:00:00 2001 From: Petr Leo Compel Date: Thu, 1 Feb 2024 13:57:55 +0100 Subject: [PATCH] fix: `Zone`, `AMMode` model parse #94 --- custom_components/hikvision_axpro/model.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/custom_components/hikvision_axpro/model.py b/custom_components/hikvision_axpro/model.py index 7a9646f..2fb60d6 100644 --- a/custom_components/hikvision_axpro/model.py +++ b/custom_components/hikvision_axpro/model.py @@ -507,6 +507,7 @@ def to_dict(self) -> dict: class AMMode(Enum): ARM = "arm" + DISARM = "disarm" class ArmModeConf(Enum): @@ -786,7 +787,12 @@ def from_dict(obj: Any) -> 'ZoneConfig': _LOGGER.warning("Detector info: %s", obj) detector_access_mode = None anti_masking_enabled = from_union([from_bool, from_none], obj.get("antiMaskingEnabled")) - am_mode = from_union([AMMode, from_none], obj.get("AMMode")) + try: + am_mode = from_union([AMMode, from_none], obj.get("AMMode")) + except: + _LOGGER.warning("Invalid AMMode %s", obj.get("AMMode")) + _LOGGER.warning("Detector info: %s", obj) + am_mode = None am_delay_time = from_union([from_int, from_none], obj.get("AMDelayTime")) pulse_sensitivity = from_union([from_int, from_none], obj.get("pulseSensitivity")) alarm_resistence = from_union([from_float, from_none], obj.get("alarmResistence"))