diff --git a/custom_components/olarm_sensors/olarm_api.py b/custom_components/olarm_sensors/olarm_api.py index 86e3744..fc6f169 100644 --- a/custom_components/olarm_sensors/olarm_api.py +++ b/custom_components/olarm_sensors/olarm_api.py @@ -377,10 +377,13 @@ async def get_pgm_zones(self, devices_json) -> list: return: (list): The pgm's for the alarm panel. """ try: - pgm_state = devices_json["deviceState"]["pgm"] - pgm_labels = devices_json["deviceProfile"]["pgmLabels"] - pgm_limit = devices_json["deviceProfile"]["pgmLimit"] - pgm_setup = devices_json["deviceProfile"]["pgmControl"] + if 'pgm' in devices_json["deviceState"] and 'pgmLabels' in devices_json["deviceProfile"] and 'pgmLimit' in devices_json["deviceProfile"] and 'pgmControl' in devices_json["deviceProfile"]: + pgm_state = devices_json["deviceState"]["pgm"] + pgm_labels = devices_json["deviceProfile"]["pgmLabels"] + pgm_limit = devices_json["deviceProfile"]["pgmLimit"] + pgm_setup = devices_json["deviceProfile"]["pgmControl"] + else: + return [] except (DictionaryKeyError, KeyError): # Error with PGM setup from Olarm app. Skipping PGM's @@ -440,9 +443,21 @@ async def get_ukey_zones(self, devices_json) -> list: return: (list): The utility keys for the alarm panel. """ - ukey_labels = devices_json["deviceProfile"]["ukeysLabels"] - ukey_limit = devices_json["deviceProfile"]["ukeysLimit"] - ukey_state = devices_json["deviceProfile"]["ukeysControl"] + try: + if 'ukeysLabels' in devices_json["deviceProfile"] and 'ukeysLimit' in devices_json["deviceProfile"] and 'ukeysControl' in devices_json["deviceProfile"]: + ukey_labels = devices_json["deviceProfile"]["ukeysLabels"] + ukey_limit = devices_json["deviceProfile"]["ukeysLimit"] + ukey_state = devices_json["deviceProfile"]["ukeysControl"] + else: + return [] + + except (DictionaryKeyError, KeyError): + # Error with Ukey setup from Olarm app. Skipping Ukey's + LOGGER.error( + "Error getting Ukey setup data for Olarm device (%s)", self.device_id + ) + return [] + ukeys = [] try: for i in range(0, ukey_limit): diff --git a/hacs.json b/hacs.json index a6d97ed..fc7deee 100644 --- a/hacs.json +++ b/hacs.json @@ -4,6 +4,6 @@ "description": "Integration for Olarm devices", "domains": ["binary_sensor", "alarm_control_panel", "button", "switch"], "documentation": "https://github.com/rainepretorius/olarm-ha-integration/blob/main/README.md", - "version": "2.2.6", + "version": "2.2.7", "iot_class": "cloud_push" }