diff --git a/Modules/command.py b/Modules/command.py index f2cfbd0f9..d38834ae8 100644 --- a/Modules/command.py +++ b/Modules/command.py @@ -42,6 +42,7 @@ tuya_lidl_set_mode, tuya_trv_brt100_set_mode, tuya_trv_mode, tuya_trv_onoff, tuya_trv_switch_onoff) +from Modules.danfoss import danfoss_on_off from Modules.tuyaTS0601 import ts0601_actuator, ts0601_extract_data_point_infos from Modules.zigateConsts import (THERMOSTAT_LEVEL_2_MODE, THERMOSTAT_LEVEL_3_MODE, ZIGATE_EP) @@ -504,7 +505,10 @@ def mgtCommand(self, Devices, Unit, Command, Level, Color): elif DeviceType == "ThermoOnOff": self.log.logging("Command", "Debug", "ThermoOnOff - requested Off", NWKID) - tuya_trv_onoff(self, NWKID, 0x00) + if "Model" in self.ListOfDevices[NWKID] and self.ListOfDevices[NWKID]["Model"] in ("eTRV0100"): + danfoss_on_off(self, NWKID, 0x00) + else: + tuya_trv_onoff(self, NWKID, 0x00) UpdateDevice_v2(self, Devices, Unit, 0, "Off", BatteryLevel, SignalLevel, ForceUpdate_=forceUpdateDev) elif DeviceType == "ShutterCalibration": @@ -689,7 +693,10 @@ def mgtCommand(self, Devices, Unit, Command, Level, Color): thermostat_Mode(self, NWKID, "Heat") elif DeviceType == "ThermoOnOff": - tuya_trv_onoff(self, NWKID, 0x01) + if "Model" in self.ListOfDevices[NWKID] and self.ListOfDevices[NWKID]["Model"] in ("eTRV0100"): + danfoss_on_off(self, NWKID, 0x01) + else: + tuya_trv_onoff(self, NWKID, 0x01) UpdateDevice_v2(self, Devices, Unit, 1, "On", BatteryLevel, SignalLevel, ForceUpdate_=forceUpdateDev) elif DeviceType == "ShutterCalibration": diff --git a/Modules/danfoss.py b/Modules/danfoss.py index 609e2f3fb..84e6d5bd1 100644 --- a/Modules/danfoss.py +++ b/Modules/danfoss.py @@ -387,3 +387,39 @@ def danfoss_viewdirection(self, NwkId, viewdirection): write_attribute(self, NwkId, ZIGATE_EP, EPout, cluster_id, manuf_id, manuf_spec, Hattribute, data_type, Hdata, ackIsDisabled=False) read_attribute(self, NwkId, ZIGATE_EP, EPout, cluster_id, "00", manuf_spec, manuf_id, 1, Hattribute, ackIsDisabled=False) + + +def danfoss_on_off(self, NwkId, on): + # 0 = window closed 1 = window opened + if on == 0: + window_opened = 1 + elif on == 1: + window_opened = 0 + else: + return + + manuf_id = "1246" + manuf_spec = "01" + cluster_id = "%04x" % 0x0201 + + EPout = "01" + for tmpEp in self.ListOfDevices[NwkId]["Ep"]: + if "0201" in self.ListOfDevices[NwkId]["Ep"][tmpEp]: + EPout = tmpEp + + Hattribute = "%04x" % 0x4003 + data_type = "10" # boolean + self.log.logging("Danfoss", "Debug", "danfoss_on_off: %s" % window_opened, nwkid=NwkId) + + Hdata = "%02x" % window_opened + + self.log.logging( + "Danfoss", + "Debug", + "danfoss_on_onff for %s with value %s / cluster: %s, attribute: %s type: %s" % (NwkId, Hdata, cluster_id, Hattribute, data_type), + nwkid=NwkId, + ) + + write_attribute(self, NwkId, ZIGATE_EP, EPout, cluster_id, manuf_id, manuf_spec, Hattribute, data_type, Hdata, ackIsDisabled=False) + read_attribute(self, NwkId, ZIGATE_EP, EPout, cluster_id, "00", manuf_spec, manuf_id, 1, Hattribute, ackIsDisabled=False) + diff --git a/Modules/input.py b/Modules/input.py index ed28d22b5..db167fe15 100644 --- a/Modules/input.py +++ b/Modules/input.py @@ -492,7 +492,8 @@ def Decode0110(self, Devices, MsgData, MsgLQI): # Write Attribute request timeStamped(self, MsgSrcAddr, 0x0110) lastSeenUpdate(self, Devices, NwkId=MsgSrcAddr) - for idx in range(24, len(MsgData), 4): + idx = 24 + while idx < len(MsgData): Attribute = MsgData[idx : idx + 4] idx += 4 DataType = MsgData[idx : idx + 2] @@ -500,6 +501,7 @@ def Decode0110(self, Devices, MsgData, MsgLQI): # Write Attribute request lendata = MsgData[idx : idx + 4] idx += 4 DataValue = MsgData[idx : idx + int(lendata,16) * 2] + idx += int(lendata, 16) * 2 self.log.logging( "Input", "Debug", "Decode0110 - Sqn: %s NwkId: %s Ep: %s Cluster: %s Manuf: %s Attribute: %s Type: %s Value: %s" % ( MsgSqn, MsgSrcAddr, MsgSrcEp, MsgClusterId, MsgManufCode, Attribute, DataType, DataValue), ) @@ -4144,7 +4146,7 @@ def Decode8095(self, Devices, MsgData, MsgLQI): MajDomoDevice(self, Devices, MsgSrcAddr, "02", "0006", "01") else: - MajDomoDevice(self, Devices, MsgSrcAddr, MsgEP, "0006", str(int(MsgCmd, 16))) + MajDomoDevice(self, Devices, MsgSrcAddr, MsgEP, "0006", MsgCmd) self.ListOfDevices[MsgSrcAddr]["Ep"][MsgEP][MsgClusterId]["0000"] = "Cmd: %s, %s" % (MsgCmd, unknown_) self.log.logging( "Input", "Log", "Decode8095 - Model: %s SQN: %s, Addr: %s, Ep: %s, Cluster: %s, Cmd: %s, Unknown: %s " % ( _ModelName, MsgSQN, MsgSrcAddr, MsgEP, MsgClusterId, MsgCmd, unknown_), MsgSrcAddr, ) diff --git a/Modules/pluginModels.py b/Modules/pluginModels.py index e454dcaee..d20c92f6e 100644 --- a/Modules/pluginModels.py +++ b/Modules/pluginModels.py @@ -109,7 +109,7 @@ def check_found_plugin_model( self, model, manufacturer_name=None, manufacturer_ '_TZ3000_amdymr7l', '_TZ3000_z1pnpsdo', '_TZ3000_ksw8qtmt', '_TZ3000_nzkqcvvs', '_TZ3000_1h2x4akh', '_TZ3000_9vo5icau', '_TZ3000_cehuw1lw', '_TZ3000_ko6v90pg', '_TZ3000_f1bapcit', '_TZ3000_cjrngdr3', '_TZ3000_zloso4jk', '_TZ3000_r6buo8ba', - '_TZ3000_iksasdbv', '_TZ3000_dd8wwzcy', '_TZ3000_hdopuwv6'], + '_TZ3000_iksasdbv', '_TZ3000_dd8wwzcy', '_TZ3000_hdopuwv6', '_TZ3000_ynmowqk2'], "ManufId": [], "PluginModelName": "TS011F-plug" }, diff --git a/Modules/readClusters.py b/Modules/readClusters.py index 310a27083..d848e99a4 100644 --- a/Modules/readClusters.py +++ b/Modules/readClusters.py @@ -1379,8 +1379,15 @@ def Cluster0201(self, Devices, MsgSQN, MsgSrcAddr, MsgSrcEp, MsgClusterId, MsgAt elif MsgAttrID in ("4000", "4003", "4010", "4011", "4012", "4013", "4014", "4015", "4020", "4030", "4031") and danfoss: checkAndStoreAttributeValue(self, MsgSrcAddr, MsgSrcEp, MsgClusterId, MsgAttrID, MsgClusterData) - if MsgAttrID == "4003" and self.ListOfDevices[MsgSrcAddr]["Model"] in ("eTRV0100", "eT093WRO"): + if MsgAttrID == "4000" and self.ListOfDevices[MsgSrcAddr]["Model"] in ("eTRV0100"): # Open Window Detection for Danfoss eTRV + if value in [ 3, 4 ]: + value = "01" + else: + value = "00" + MajDomoDevice(self, Devices, MsgSrcAddr, MsgSrcEp, "0500", value) + if MsgAttrID == "4003" and self.ListOfDevices[MsgSrcAddr]["Model"] in ("eTRV0100", "eT093WRO"): + # External Open Window Detection for Danfoss eTRV MajDomoDevice(self, Devices, MsgSrcAddr, MsgSrcEp, "0500", value) elif MsgAttrID in ("e010", "e011", "e012", "e013", "e014", "e030", "e031", "e020"):