Skip to content

Commit

Permalink
Device/remote legrand toggle (#1679)
Browse files Browse the repository at this point in the history
Remote Switch seems to communicate also on Cluster 000f/f000
  • Loading branch information
pipiche38 authored Dec 9, 2023
1 parent 6e26442 commit 0ae0857
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
23 changes: 13 additions & 10 deletions Modules/domoMaj.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,17 +1169,20 @@ def MajDomoDevice(self, Devices, NWKID, Ep, clusterID, value, Attribute_="", Col
self.log.logging("Widget", "Debug", "------> Switch off as System Mode is Off")
UpdateDevice_v2(self, Devices, DeviceUnit, 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, DeviceUnit, 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]))
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, DeviceUnit, nValue, sValue, BatteryLevel, SignalLevel, ForceUpdate_=_ForceUpdate)
else:
self.log.logging( "Widget", "Error", "------> len(SWITCH_SELECTORS[ %s ][ %s ]) == %s" % (
WidgetType, value, len(SWITCH_SELECTORS[WidgetType])), NWKID, )
else:
self.log.logging( "Widget", "Error", "------> len(SWITCH_SELECTORS[ %s ][ %s ]) == %s" % (
WidgetType, value, len(SWITCH_SELECTORS[WidgetType])), NWKID, )
self.log.logging("Widget", "Error", "------> Auto Update (%s %s) not found in SWITCH_SELECTORS" % ( WidgetType, value))

if "WindowCovering" in ClusterType: # 0x0102
if WidgetType in ("VenetianInverted", "Venetian", "Vanne", "VanneInverted", "WindowCovering", "Curtain", "CurtainInverted", "Blind"):
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 0ae0857

Please sign in to comment.