Skip to content

Commit

Permalink
Merge branch 'wip-stable-7.1.6' into refactor-dim-lights
Browse files Browse the repository at this point in the history
  • Loading branch information
pipiche38 committed Dec 9, 2023
2 parents be5f77c + 0ae0857 commit 514cc48
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 24 deletions.
26 changes: 16 additions & 10 deletions Modules/domoMaj.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,17 +1158,23 @@ def _domo_maj_one_cluster_type_entry( self, Devices, NwkId, Ep, device_id_ieee,
self.log.logging("Widget", "Debug", "------> Switch off as System Mode is Off")
UpdateDevice_v2(self, Devices, device_unit, 0, "00", BatteryLevel, SignalLevel)

elif WidgetType in SWITCH_SELECTORS and value in SWITCH_SELECTORS[WidgetType]:
self.log.logging("Widget", "Debug", "------> Auto Update %s" % str(SWITCH_SELECTORS[WidgetType][value]))
if len(SWITCH_SELECTORS[WidgetType][value]) == 2:
nValue, sValue = SWITCH_SELECTORS[WidgetType][value]
_ForceUpdate = SWITCH_SELECTORS[WidgetType]["ForceUpdate"]
self.log.logging( "Widget", "Debug", "------> Switch update WidgetType: %s with %s" % (
WidgetType, str(SWITCH_SELECTORS[WidgetType])), NwkId, )
UpdateDevice_v2(self, Devices, device_unit, nValue, sValue, BatteryLevel, SignalLevel, ForceUpdate_=_ForceUpdate)
else:
if WidgetType in SWITCH_SELECTORS and value in SWITCH_SELECTORS[WidgetType]:
self.log.logging("Widget", "Debug", "------> Auto Update %s" % str(SWITCH_SELECTORS[WidgetType][value]))

selector_values = SWITCH_SELECTORS[WidgetType][value]

if len(selector_values) == 2:
nValue, sValue = selector_values
_ForceUpdate = SWITCH_SELECTORS[WidgetType]["ForceUpdate"]

self.log.logging("Widget", "Debug", f"------> Switch update WidgetType: {WidgetType} with {str(SWITCH_SELECTORS[WidgetType])}", NwkId)
UpdateDevice_v2(self, Devices, device_unit, nValue, sValue, BatteryLevel, SignalLevel, ForceUpdate_=_ForceUpdate)
else:
self.log.logging("Widget", "Error", f"------> len(SWITCH_SELECTORS[{WidgetType}][{value}]) == {len(selector_values)}", NwkId)
else:
self.log.logging( "Widget", "Error", "------> len(SWITCH_SELECTORS[ %s ][ %s ]) == %s" % (
WidgetType, value, len(SWITCH_SELECTORS[WidgetType])), NwkId, )
self.log.logging("Widget", "Log", f"------> Auto Update requested for NwkId: {NwkId} {ClusterType} {WidgetType} {value} not found in SWITCH_SELECTORS")


if "WindowCovering" in ClusterType and WidgetType in ("VenetianInverted", "Venetian", "Vanne", "VanneInverted", "WindowCovering", "Curtain", "CurtainInverted", "Blind"):
_value = int(value, 16)
Expand Down
33 changes: 19 additions & 14 deletions Modules/readZclClusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,32 +353,37 @@ def cluster_attribute_retrieval(self, ep, cluster, attribute, parameter, model=N


def action_majdomodevice( self, Devices, MsgSrcAddr, MsgSrcEp, MsgClusterId, MsgAttrID, device_model, value ):

DOMO_DEVICE_FORMATER = {
"str": str,
"str_2digits": lambda x: "%02d" % int(x),
"str_4digits": lambda x: "%04d" % int(x),
"strhex": lambda x: "%x" % x,
"str2hex": lambda x: "%02x" % x,
"str4hex": lambda x: "%04x" % x
}

self.log.logging( "ZclClusters", "Debug", "action_majdomodevice - %s/%s %s %s %s %s" %(
MsgSrcAddr, MsgSrcEp, MsgClusterId, MsgAttrID, device_model, value ))
MsgSrcAddr, MsgSrcEp, MsgClusterId, MsgAttrID, device_model, value ))

_majdomo_formater = cluster_attribute_retrieval( self, MsgSrcEp, MsgClusterId, MsgAttrID, "DomoDeviceFormat", model=device_model)
self.log.logging( "ZclClusters", "Debug", " _majdomo_formater: %s" %_majdomo_formater)

if get_device_config_param( self, MsgSrcAddr, "disableBinaryInputCluster") and MsgClusterId == "000f":
return

majValue = value
if _majdomo_formater:
if _majdomo_formater == "str":
majValue = str( value )
elif _majdomo_formater == "strhex":
majValue = "%x" %value


majValue = DOMO_DEVICE_FORMATER[ _majdomo_formater ](value) if (_majdomo_formater and _majdomo_formater in DOMO_DEVICE_FORMATER) else value
self.log.logging( "ZclClusters", "Debug", " _majdomo_formater: %s %s -> %s" %(_majdomo_formater, value, majValue))

_majdomo_cluster = cluster_attribute_retrieval( self, MsgSrcEp, MsgClusterId, MsgAttrID, "UpdDomoDeviceWithCluster", model=device_model)
self.log.logging( "ZclClusters", "Debug", " _majdomo_cluster: %s" %_majdomo_cluster)

majCluster = _majdomo_cluster if _majdomo_cluster is not None else MsgClusterId

_majdomo_attribute = cluster_attribute_retrieval( self, MsgSrcEp, MsgClusterId, MsgAttrID, "UpdDomoDeviceWithAttribute", model=device_model)
self.log.logging( "ZclClusters", "Debug", " _majdomo_attribute: %s" %_majdomo_attribute)

majAttribute = _majdomo_attribute if _majdomo_attribute is not None else ""

self.log.logging( "ZclClusters", "Debug", " _majdomo_attribute: %s -> %s" %(_majdomo_attribute, majAttribute))

MajDomoDevice(self, Devices, MsgSrcAddr, MsgSrcEp, majCluster, majValue, Attribute_=majAttribute)


Expand Down

0 comments on commit 514cc48

Please sign in to comment.