Skip to content

Commit

Permalink
resilience on handling the onoff_poweron settings
Browse files Browse the repository at this point in the history
  • Loading branch information
pipiche38 committed Feb 17, 2024
1 parent f2b18f0 commit d0e48ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 9 additions & 4 deletions Modules/onoff_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from Modules.enki import is_enky_device
from Modules.philips import is_philips_device
from Modules.readAttributes import ReadAttributeRequest_0006_400x
from Modules.tools import get_deviceconf_parameter_value, getListOfEpForCluster
from Modules.tools import (get_deviceconf_parameter_value,
getListOfEpForCluster, is_int)
from Modules.tuya import (get_tuya_attribute, is_tuya_switch_relay,
tuya_switch_relay_status)
from Modules.zigateConsts import ZIGATE_EP
Expand Down Expand Up @@ -67,9 +68,13 @@ def onoff_startup_onoff_mode(self, nwkid, ep, value):
self.log.logging( "onoffSettings", "Debug", f"onoff_startup_onoff_mode for {nwkid}/{ep} - value: {value}", nwkid )

if isinstance(value, str):
old_value = value
value = int(value)
self.log.logging( "onoffSettings", "Log", f"onoff_startup_onoff_mode for {nwkid}/{ep} - value: {old_value} converted to {value}", nwkid )
if is_int(value):
old_value = value
value = int(value)
self.log.logging( "onoffSettings", "Log", f"onoff_startup_onoff_mode for {nwkid}/{ep} - value: {old_value} converted to {value}", nwkid )
else:
self.log.logging( "onoffSettings", "Error", f"onoff_startup_onoff_mode for {nwkid}/{ep} - value error {value}", nwkid )
return

write_attribute(
self,
Expand Down
8 changes: 6 additions & 2 deletions Modules/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
from Modules.pluginDbAttributes import STORE_CONFIGURE_REPORTING
from Modules.zigateConsts import HEARTBEAT

HEX_DIGIT = "0123456789abcdefABCDEF"
INT_DIGIT = "0123456789"

def is_hex(s):
hex_digits = set("0123456789abcdefABCDEF")
return all(char in hex_digits for char in s)
return all(char in HEX_DIGIT for char in s)

def is_int(s):
return all(char in INT_DIGIT for char in s)

def returnlen(taille, value):
while len(value) < taille:
Expand Down

0 comments on commit d0e48ab

Please sign in to comment.