From b0414421e07d8467e9f4e2db41e04f49cd93ed5b Mon Sep 17 00:00:00 2001 From: Pergola Fabio Date: Tue, 12 Sep 2023 19:24:10 +0200 Subject: [PATCH] fix for com/lock result = "" --- hikvision-doorbell/src/doorbell.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hikvision-doorbell/src/doorbell.py b/hikvision-doorbell/src/doorbell.py index 9b4bdd2..0b18e45 100644 --- a/hikvision-doorbell/src/doorbell.py +++ b/hikvision-doorbell/src/doorbell.py @@ -208,7 +208,7 @@ def isapi_door_capabilities() -> int: logger.debug("Error parsing: {}", io_doors_xml) return 0 # Error out if we don't find attribute `max` inside the `doorNo` element - if door_number_element.text is None: + if door_number_element is None or door_number_element.text is None: # Print a string representation of the response XML logger.debug("No door relays found for the indoor device") return 0 @@ -300,7 +300,7 @@ def isapi_device_info() -> int: root = ET.fromstring(electro_lock_xml) electro_lock_xml_element = root.find('{*}electroLockNum') # Error out if we don't find attribute `max` inside the `doorNo` element - if electro_lock_xml_element.text is None : + if electro_lock_xml_element is None or electro_lock_xml_element.text is None: # Print a string representation of the response XML logger.info("No electro locks found for the outdoor device") raise RuntimeError('Cannot find `electroLockNum` node in XML response') @@ -332,7 +332,7 @@ def isapi_device_info() -> int: root = ET.fromstring(io_coms_xml) com_number_element = root.find('{*}alarmOutNum') # Error out if we don't find attribute `max` inside the `doorNo` element - if com_number_element.text is None : + if com_number_element is None or com_number_element.text is None: # Print a string representation of the response XML logger.debug("No com ports found for the indoor device") return 0