Skip to content

Commit

Permalink
Merge pull request #91 from Cha0s2nd/main
Browse files Browse the repository at this point in the history
Fix for missing PGMs and Ukeys
  • Loading branch information
rainepretorius authored Oct 31, 2023
2 parents 644e1e0 + b32888e commit 3cf0d0e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
29 changes: 22 additions & 7 deletions custom_components/olarm_sensors/olarm_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 3cf0d0e

Please sign in to comment.