From 4d8198be292657b5056ba900bc7a02f7f10c9083 Mon Sep 17 00:00:00 2001 From: Patrick Pichon Date: Wed, 1 Nov 2023 21:44:11 +0100 Subject: [PATCH] use a try/except to protect the binascii.unhexlify() --- DevicesModules/custom_zlinky.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/DevicesModules/custom_zlinky.py b/DevicesModules/custom_zlinky.py index 4913d8851..daab5f734 100644 --- a/DevicesModules/custom_zlinky.py +++ b/DevicesModules/custom_zlinky.py @@ -598,9 +598,14 @@ def zlinky_cluster_lixee_private(self, Devices, nwkid, ep, cluster, attribut, va elif attribut == "0217": # Standard : STGE self.log.logging( "ZLinky", "Log", "STGE raw Value: %s" % ( value )) - stge = binascii.unhexlify( value ).decode("utf-8") - self.log.logging( "ZLinky", "Log", "STGE unhexlify Value: %s" % ( stge )) - self.log.logging( "ZLinky", "Log", "STGE decoded : %s" % ( decode_STEG( stge ) )) + try: + stge = binascii.unhexlify( value ).decode("utf-8") + self.log.logging( "ZLinky", "Log", "STGE unhexlify Value: %s/%s" % ( value, stge )) + except Exception as e: + self.log.logging( "ZLinky", "Log", "STGE Value: %s" % ( value )) + stge = value + + self.log.logging( "ZLinky", "Log", "STGE decoded %s : %s" % ( stge, decode_STEG( stge ) )) store_ZLinky_infos( self, nwkid, "STGE", decode_STEG( stge )) checkAndStoreAttributeValue(self, nwkid, ep, cluster, attribut, stge) @@ -661,5 +666,4 @@ def zlinky_cluster_lixee_private(self, Devices, nwkid, ep, cluster, attribut, va elif attribut == "0300": # Linky Mode - update_zlinky_device_model_if_needed( self, nwkid ) - + update_zlinky_device_model_if_needed( self, nwkid ) \ No newline at end of file