def tuya_watertimer_command(self, NwkId, onoff, gang=0x01): self.log.logging( "Tuya", "Debug", "tuya_switch_command - %s OpenClose: %s on gang: %s" % (NwkId, onoff, gang), NwkId) # determine which Endpoint if gang not in (0x01, 0x02, 0x03): self.log.logging("Tuya", "Error", "tuya_switch_command - Unexpected Gang: %s" % gang) return if onoff not in ("00", "01"): self.log.logging("Tuya", "Error", "tuya_switch_command - Unexpected OnOff: %s" % onoff) return EPout = "01" cluster_frame = "11" cmd = "00" # Command if onoff == "01": sqn = get_and_inc_SQN(self, NwkId) action = "0b02" data = "0000012c" tuya_cmd(self, NwkId, EPout, cluster_frame, sqn, cmd, action, data) sqn = get_and_inc_SQN(self, NwkId) action = "%02x01" % gang # Data Type 0x01 - Bool data = onoff self.log.logging( "Tuya", "Debug", "tuya_switch_command - action: %s data: %s" % (action, data)) tuya_cmd(self, NwkId, EPout, cluster_frame, sqn, cmd, action, data)
def tuya_sirene_registration(self, nwkid): self.log.logging("Tuya", "Debug", "tuya_sirene_registration - Nwkid: %s" % nwkid) EPout = "01" payload = "11" + get_and_inc_SQN(self, nwkid) + "10" + "002a" raw_APS_request( self, nwkid, EPout, "ef00", "0104", payload, zigate_ep=ZIGATE_EP, ackIsDisabled=is_ack_tobe_disabled(self, nwkid), ) # (1) 3 x Write Attribute Cluster 0x0000 - Attribute 0xffde - DT 0x20 - Value: 0x13 EPout = "01" write_attribute(self, nwkid, ZIGATE_EP, EPout, "0000", "0000", "00", "ffde", "20", "13", ackIsDisabled=False) # (2) Cmd 0xf0 send on Cluster 0x0000 - no data payload = "11" + get_and_inc_SQN(self, nwkid) + "f0" raw_APS_request( self, nwkid, EPout, "0000", "0104", payload, zigate_ep=ZIGATE_EP, ackIsDisabled=is_ack_tobe_disabled(self, nwkid), ) # (3) Cmd 0x03 on Cluster 0xef00 (Cluster Specific) payload = "11" + get_and_inc_SQN(self, nwkid) + "03" raw_APS_request( self, nwkid, EPout, "ef00", "0104", payload, zigate_ep=ZIGATE_EP, ackIsDisabled=is_ack_tobe_disabled(self, nwkid), ) # Set the Siren to °C tuya_siren_temp_unit(self, nwkid, unit="C")
def tuya_siren_humi_alarm(self, nwkid, onoff): self.log.logging("Tuya", "Debug", "tuya_siren_humi_alarm - %s onoff: %s" % (nwkid, onoff)) min_humi = 25 max_humi = 75 if onoff: if ( "Param" in self.ListOfDevices[nwkid] and "HumidityMinAlarm" in self.ListOfDevices[nwkid]["Param"] and isinstance(self.ListOfDevices[nwkid]["Param"]["HumidityMinAlarm"], int) ): min_humi = self.ListOfDevices[nwkid]["Param"]["HumidityMinAlarm"] if ( "Param" in self.ListOfDevices[nwkid] and "HumidityMaxAlarm" in self.ListOfDevices[nwkid]["Param"] and isinstance(self.ListOfDevices[nwkid]["Param"]["HumidityMaxAlarm"], int) ): max_humi = self.ListOfDevices[nwkid]["Param"]["HumidityMaxAlarm"] tuya_siren_alarm_humidity(self, nwkid, min_humi, max_humi) # determine which Endpoint EPout = "01" sqn = get_and_inc_SQN(self, nwkid) cluster_frame = "11" cmd = "00" # Command action = "%04x" % struct.unpack("H", struct.pack(">H", 0x0172))[0] data = "%02x" % onoff tuya_cmd(self, nwkid, EPout, cluster_frame, sqn, cmd, action, data)
def tuya_garage_door_action(self, NwkId, action): # 000f/0101/0001/00 # 0010/0101/0001/01 EPout = "01" sqn = get_and_inc_SQN(self, NwkId) cluster_frame = "11" cmd = "00" # Command action = "0101" data = "%02x" % int(action) tuya_cmd(self, NwkId, EPout, cluster_frame, sqn, cmd, action, data)
def legrand_fc40(self, nwkid, Mode): # With the permission of @Thorgal789 who did the all reverse enginnering of this cluster CABLE_OUTLET_MODE = { "Confort": 0x00, "Confort -1": 0x01, "Confort -2": 0x02, "Eco": 0x03, "Frost Protection": 0x04, "Off": 0x05, } if Mode not in CABLE_OUTLET_MODE: Domoticz.Error(" Bad Mode : %s for %s" % (Mode, nwkid)) return Hattribute = "0000" data_type = "30" # 8bit Enum Hdata = CABLE_OUTLET_MODE[Mode] # manuf_id = "1021" # Legrand Code # manuf_spec = "01" # Manuf specific flag cluster_id = "%04x" % 0xFC40 EPout = "01" for tmpEp in self.ListOfDevices[nwkid]["Ep"]: if "fc40" in self.ListOfDevices[nwkid]["Ep"][tmpEp]: EPout = tmpEp self.log.logging( "Legrand", "Debug", "legrand %s Set Fil pilote mode - for %s with value %s / cluster: %s, attribute: %s type: %s" % (Mode, nwkid, Hdata, cluster_id, Hattribute, data_type), nwkid=nwkid, ) sqn = get_and_inc_SQN(self, nwkid) fcf = "15" # manufspec = "01" manufcode = "1021" cmd = "00" data = "%02x" % CABLE_OUTLET_MODE[Mode] payload = fcf + manufcode[2:4] + manufcode[0:2] + sqn + cmd + data raw_APS_request( self, nwkid, EPout, "fc40", "0104", payload, zigate_ep=ZIGATE_EP, ackIsDisabled=is_ack_tobe_disabled(self, nwkid), )
def zcl_raw_window_covering(self, nwkid, EPIn, EPout, command, level="00", percentage="00", groupaddrmode=False, ackIsDisabled=True): self.log.logging( "zclCommand", "Debug", "zcl_raw_window_covering %s %s %s %s %s" % (nwkid, EPout, command, level, percentage)) Cluster = "0102" WINDOW_COVERING_COMMANDS = { "Up": 0x00, "Down": 0x01, "Stop": 0x02, "GoToLiftValue": 0x04, "GoToLiftPercentage": 0x05, "GoToTiltValue": 0x07, "GoToTiltPercentage": 0x08 } if command not in WINDOW_COVERING_COMMANDS: return # Cluster Frame: # 0b xxxx xxxx # |- Frame Type: Cluster Specific (0x01) # |-- Manufacturer Specific False # |--- Command Direction: Client to Server (0) # | ---- Disable default response: True # |||- ---- Reserved : 0x000 # cluster_frame = 0b00010001 sqn = get_and_inc_SQN(self, nwkid) payload = "%02x" % cluster_frame + sqn + "%02x" % WINDOW_COVERING_COMMANDS[ command] if command in ("MovetoLevel", "MovetoLevelWithOnOff"): payload += level elif command == ("GoToLiftValue", "GoToTiltValue"): payload += percentage return raw_APS_request(self, nwkid, EPout, Cluster, "0104", payload, zigate_ep=EPIn, groupaddrmode=groupaddrmode, ackIsDisabled=ackIsDisabled)
def tuya_dimmer_onoff(self, NwkId, srcEp, OnOff): self.log.logging("Tuya", "Debug", "tuya_dimmer_onoff - %s OnOff: %s" % (NwkId, OnOff), NwkId) # determine which Endpoint EPout = "01" sqn = get_and_inc_SQN(self, NwkId) cluster_frame = "11" cmd = "00" # Command action = "0101" data = OnOff tuya_cmd(self, NwkId, EPout, cluster_frame, sqn, cmd, action, data)
def tuya_curtain_openclose(self, NwkId, openclose): self.log.logging( "Tuya", "Debug", "tuya_curtain_openclose - %s OpenClose: %s" % (NwkId, openclose), NwkId) # determine which Endpoint EPout = "01" sqn = get_and_inc_SQN(self, NwkId) cluster_frame = "11" cmd = "00" # Command action = "0101" data = openclose tuya_cmd(self, NwkId, EPout, cluster_frame, sqn, cmd, action, data)
def rawaps_read_attribute_req(self, nwkid, EpIn, EpOut, Cluster, direction, manufacturer_spec, manufacturer, Attr, ackIsDisabled=True): self.log.logging( "zclCommand", "Debug", "rawaps_read_attribute_req %s %s %s %s %s %s %s %s" % (nwkid, EpIn, EpOut, Cluster, direction, manufacturer_spec, manufacturer, Attr)) cmd = "00" # Read Attribute Command Identifier # Cluster Frame: # 0b xxxx xxxx # |- Frame Type: Cluster Specific (0x00) # |-- Manufacturer Specific False # |--- Command Direction: Client to Server (0) # | ---- Disable default response: True # |||- ---- Reserved : 0x000 # cluster_frame = 0b00010000 if manufacturer_spec == "01": cluster_frame += 0b00000100 fcf = "%02x" % cluster_frame sqn = get_and_inc_SQN(self, nwkid) payload = fcf if manufacturer_spec == "01": payload += manufacturer_spec + manufacturer[4:2] + manufacturer[0:2] payload += sqn + cmd idx = 0 while idx < len(Attr): attribute = Attr[idx:idx + 4] idx += 4 payload += "%04x" % struct.unpack( ">H", struct.pack("H", int(attribute, 16)))[0] return raw_APS_request(self, nwkid, EpOut, Cluster, "0104", payload, zigate_ep=EpIn, ackIsDisabled=ackIsDisabled)
def rawaps_write_attribute_req(self, nwkid, EPin, EPout, cluster, manuf_id, manuf_spec, attribute, data_type, data, ackIsDisabled=True): self.log.logging( "zclCommand", "Debug", "rawaps_write_attribute_req %s %s %s %s %s %s %s %s %s" % (nwkid, EPin, EPout, cluster, manuf_id, manuf_spec, attribute, data_type, data)) cmd = "02" cluster_frame = 0b00010000 if manuf_spec == "01": cluster_frame += 0b00000100 fcf = "%02x" % cluster_frame sqn = get_and_inc_SQN(self, nwkid) payload = fcf if manuf_spec == "01": payload += manuf_spec + "%04x" % struct.unpack( ">H", struct.pack("H", int(manuf_id, 16)))[0] payload += sqn + cmd payload += "%04x" % struct.unpack(">H", struct.pack( "H", int(attribute, 16)))[0] payload += data_type if data_type in ("10", "18", "20", "28", "30"): payload += data elif data_type in ("09", "16", "21", "29", "31"): payload += "%04x" % struct.unpack(">H", struct.pack( "H", int(data, 16)))[0] elif data_type in ("22", "2a"): payload += "%06x" % struct.unpack(">i", struct.pack( "I", int(data, 16)))[0] elif data_type in ("23", "2b", "39"): payload += "%08x" % struct.unpack(">f", struct.pack( "I", int(data, 16)))[0] else: payload += data return raw_APS_request(self, nwkid, EPout, cluster, "0104", payload, zigate_ep=EPin, ackIsDisabled=ackIsDisabled)
def tuya_energy_childLock(self, NwkId, lock=0x01): # 0012 1d 01 0001 00 Child Unlock # 0011 1d 01 0001 01 Child Lock EPout = "01" sqn = get_and_inc_SQN(self, NwkId) cluster_frame = "11" cmd = "00" # Command action = "1d01" data = "%02x" % lock self.log.logging( "Tuya", "Debug", "tuya_energy_childLock - action: %s data: %s" % (action, data)) tuya_cmd(self, NwkId, EPout, cluster_frame, sqn, cmd, action, data)
def tuya_curtain_lvl(self, NwkId, percent): self.log.logging("Tuya", "Debug", "tuya_curtain_lvl - %s percent: %s" % (NwkId, percent), NwkId) level = percent # determine which Endpoint EPout = "01" sqn = get_and_inc_SQN(self, NwkId) cluster_frame = "11" cmd = "00" # Command action = "0202" data = "%08x" % level tuya_cmd(self, NwkId, EPout, cluster_frame, sqn, cmd, action, data)
def tuya_siren_alarm_melody(self, nwkid, melody): # 18-Melodies 1 -> 18 ==> 0x00 -- 0x11 # 1- 00 40 6604 0001 00 # 2- 00 41 6604 0001 01 self.log.logging("Tuya", "Debug", "tuya_siren_alarm_melody - %s onoff: %s" % (nwkid, melody)) # determine which Endpoint EPout = "01" sqn = get_and_inc_SQN(self, nwkid) cluster_frame = "11" cmd = "00" # Command action = "%04x" % struct.unpack("H", struct.pack(">H", 0x0466))[0] data = "%02x" % melody tuya_cmd(self, nwkid, EPout, cluster_frame, sqn, cmd, action, data)
def tuya_siren_alarm_volume(self, nwkid, volume): # 0-Max, 1-Medium, 2-Low # 0- 95db 00 3e 7404 0001 00 # 1- 80db 00 3d 7404 0001 01 # 2- 70db 00 3f 7404 0001 02 self.log.logging("Tuya", "Debug", "tuya_siren_alarm_volume - %s volume: %s" % (nwkid, volume)) # determine which Endpoint EPout = "01" sqn = get_and_inc_SQN(self, nwkid) cluster_frame = "11" cmd = "00" # Command action = "%04x" % struct.unpack("H", struct.pack(">H", 0x0474))[0] data = "%02x" % volume tuya_cmd(self, nwkid, EPout, cluster_frame, sqn, cmd, action, data)
def ffad_send_manuf_specific_cmd(self, NwkId, payload): cluster_frame = "05" sqn = get_and_inc_SQN(self, NwkId) EPout = get_ffad_endpoint(self, NwkId) data = cluster_frame + CASAIA_MANUF_CODE_BE + sqn data += payload raw_APS_request(self, NwkId, EPout, "ffad", "0104", data, zigate_ep=ZIGATE_EP)
def tuya_siren_alarm_duration(self, nwkid, duration): # duration in second # 0s - 00 43 6702 0004 00000000 # 10s - 00 44 6702 0004 0000000a # 250s - 00 45 6702 0004 000000fa # 300s - 00 46 6702 0004 0000012c self.log.logging("Tuya", "Debug", "tuya_siren_alarm_duration - %s duration: %s" % (nwkid, duration)) # determine which Endpoint EPout = "01" sqn = get_and_inc_SQN(self, nwkid) cluster_frame = "11" cmd = "00" # Command action = "%04x" % struct.unpack("H", struct.pack(">H", 0x0267))[0] data = "%08x" % duration tuya_cmd(self, nwkid, EPout, cluster_frame, sqn, cmd, action, data)
def assign_group_membership_to_legrand_remote(self, NwkId, Ep, leftright=None): sqn = get_and_inc_SQN(self, NwkId) cmd = "08" if leftright: cmd = "0c" self.log.logging( "Legrand", "Debug", "assign_group_membership_to_legrand_remote %s lefright: %s" % (NwkId, leftright) ) groupid = get_groupid_for_remote(self, NwkId, Ep, leftright) if groupid: LegrandGroupMemberShip = "%04x" % struct.unpack("H", struct.pack(">H", int(groupid, 16)))[0] if leftright: sendFC01Command(self, sqn, NwkId, Ep, "fc01", cmd, LegrandGroupMemberShip + leftright) else: sendFC01Command(self, sqn, NwkId, Ep, "fc01", cmd, LegrandGroupMemberShip)
def profalux_stop(self, nwkid): # determine which Endpoint EPout = "01" for tmpEp in self.ListOfDevices[nwkid]["Ep"]: if "0008" in self.ListOfDevices[nwkid]["Ep"][tmpEp]: EPout = tmpEp cluster_frame = "01" sqn = get_and_inc_SQN(self, nwkid) cmd = "03" # Ask the Tilt Blind to stop moving payload = cluster_frame + sqn + cmd raw_APS_request(self, nwkid, EPout, "0008", "0104", payload, zigate_ep=ZIGATE_EP) self.log.logging("Profalux", "Debug", "profalux_stop ++++ %s/%s payload: %s" % (nwkid, EPout, payload), nwkid)
def tuya_energy_countdown(self, NwkId, timing): # Countdown is 0x09 for Energy device # Countdown is 0x42 for Multigang Switch : https://developer.tuya.com/en/docs/iot/tuya-zigbee-multiple-switch-access-standard?id=K9ik6zvnqr09m#title-15-Countdown self.log.logging("Tuya", "Debug", "tuya_energy_countdown - %s timing: %s" % (NwkId, timing), NwkId) EPout = "01" sqn = get_and_inc_SQN(self, NwkId) cluster_frame = "11" cmd = "00" # Command action = "0902" data = "%08x" % timing tuya_cmd(self, NwkId, EPout, cluster_frame, sqn, cmd, action, data)
def raw_zcl_zcl_onoff(self, nwkid, EPIn, EpOut, command, effect="", groupaddrmode=False, ackIsDisabled=True): self.log.logging( "zclCommand", "Log", "raw_zcl_zcl_onoff %s %s %s %s %s %s" % (nwkid, EPIn, EpOut, command, effect, groupaddrmode)) Cluster = "0006" ONOFF_COMMANDS = { "Off": 0x00, "On": 0x01, "Toggle": 0x02, "OffWithEffect": 0x40, "OnWithRecallGlobalScene": 0x41, "OnWithTimedOff": 0x42, } if command not in ONOFF_COMMANDS: return # Cluster Frame: # 0b xxxx xxxx # |- Frame Type: Cluster Specific (0x01) # |-- Manufacturer Specific False # |--- Command Direction: Client to Server (0) # | ---- Disable default response: True # |||- ---- Reserved : 0x000 # cluster_frame = 0b00010001 sqn = get_and_inc_SQN(self, nwkid) payload = "%02x" % cluster_frame + sqn + "%02x" % ONOFF_COMMANDS[ command] + effect return raw_APS_request(self, nwkid, EpOut, Cluster, "0104", payload, zigate_ep=EPIn, groupaddrmode=groupaddrmode, ackIsDisabled=ackIsDisabled)
def rawaps_configure_reporting_req(self, nwkid, EpIn, EpOut, Cluster, direction, manufacturer_spec, manufacturer, attributelist, ackIsDisabled=True): self.log.logging( "zclCommand", "Debug", "rawaps_read_attribute_req %s %s %s %s %s %s %s %s" % (nwkid, EpIn, EpOut, Cluster, direction, manufacturer_spec, manufacturer, attributelist)) cmd = "06" # Configure Reporting Command Identifier # Cluster Frame: # 0b xxxx xxxx # |- Frame Type: Cluster Specific (0x00) # |-- Manufacturer Specific False # |--- Command Direction: Client to Server (0) # | ---- Disable default response: True # |||- ---- Reserved : 0x000 # cluster_frame = 0b00010000 if manufacturer_spec == "01": cluster_frame += 0b00000100 fcf = "%02x" % cluster_frame sqn = get_and_inc_SQN(self, nwkid) payload = fcf if manufacturer_spec == "01": payload += manufacturer_spec + manufacturer[4:2] + manufacturer[0:2] payload += sqn + cmd payload += build_payload_for_configure_reporting(attributelist) return raw_APS_request(self, nwkid, EpOut, Cluster, "0104", payload, zigate_ep=EpIn, ackIsDisabled=ackIsDisabled)
def tuya_siren_temp_unit(self, nwkid, unit="C"): # From °c to °F: 00 39 7001 0001 00 # 00 3b 7001 0001 00 # From °F to °c: 00 3a 7001 0001 01 # 00 3c 7001 0001 01 unit = 0x01 if unit != "F" else 0x00 self.log.logging("Tuya", "Debug", "tuya_siren_temp_unit - %s Unit Temp: %s" % (nwkid, unit)) # determine which Endpoint EPout = "01" sqn = get_and_inc_SQN(self, nwkid) cluster_frame = "11" cmd = "00" # Command action = "%04x" % struct.unpack("H", struct.pack(">H", 0x0170))[0] data = "%02x" % unit tuya_cmd(self, nwkid, EPout, cluster_frame, sqn, cmd, action, data)
def tuya_cmd_0x0000_0xf0(self, NwkId): # Seen at pairing of a WGH-JLCZ02 / TS011F and TS0201 and TS0601 (MOES BRT-100) payload = "11" + get_and_inc_SQN(self, NwkId) + "fe" raw_APS_request( self, NwkId, '01', "0000", "0104", payload, zigate_ep=ZIGATE_EP, ackIsDisabled=is_ack_tobe_disabled(self, NwkId), ) self.log.logging( "Tuya", "Debug", "tuya_cmd_0x0000_0xf0 - Nwkid: %s reset device Cmd: fe" % NwkId)
def tuya_siren_alarm_humidity(self, nwkid, min_humi_alarm, max_humi_alarm): # Max humi Min humi # 00 34 6e02 00 04 00000058 6d02 00 04 0000000c # 00 36 7201 00 01 01 self.log.logging( "Tuya", "Debug", "tuya_siren_alarm_min_humidity - %s Min Humi: %s Max Humid: %s" % (nwkid, min_humi_alarm, max_humi_alarm), ) # determine which Endpoint EPout = "01" sqn = get_and_inc_SQN(self, nwkid) cluster_frame = "11" cmd = "00" # Command action1 = "%04x" % struct.unpack("H", struct.pack(">H", 0x026E))[0] data1 = "%08x" % max_humi_alarm action2 = "%04x" % struct.unpack("H", struct.pack(">H", 0x026D))[0] data2 = "%08x" % min_humi_alarm tuya_cmd(self, nwkid, EPout, cluster_frame, sqn, cmd, action1, data1, action2, data2)
def AC211_ReadPairingCodeRequest(self, NwkId): # Command 0x00 # determine which Endpoint EPout = get_ffad_endpoint(self, NwkId) sqn = get_and_inc_SQN(self, NwkId) cluster_frame = "01" device_type = DEVICE_TYPE # Device type cmd = "00" payload = cluster_frame + sqn + cmd + device_type raw_APS_request(self, NwkId, EPout, "ffac", "0104", payload, zigate_ep=ZIGATE_EP) self.log.logging( "CasaIA", "Debug", "AC211_read_multi_pairing_code_request ++++ %s payload: %s" % (NwkId, payload), NwkId)
def tuya_energy_onoff(self, NwkId, OnOff): # 0013 01 01 0001 01 Power On # 0014 01 01 0001 00 Power Off self.log.logging("Tuya", "Debug", "tuya_energy_onoff - %s OnOff: %s" % (NwkId, OnOff), NwkId) if ("Param" in self.ListOfDevices[NwkId] and "Countdown" in self.ListOfDevices[NwkId]["Param"] and self.ListOfDevices[NwkId]["Param"]["Countdown"]): tuya_energy_countdown( self, NwkId, int(self.ListOfDevices[NwkId]["Param"]["Countdown"])) else: EPout = "01" sqn = get_and_inc_SQN(self, NwkId) cluster_frame = "11" cmd = "00" # Command action = "0101" data = OnOff tuya_cmd(self, NwkId, EPout, cluster_frame, sqn, cmd, action, data)
def profalux_MoveToLevelWithOnOff(self, nwkid, level): # determine which Endpoint EPout = "01" for tmpEp in self.ListOfDevices[nwkid]["Ep"]: if "0008" in self.ListOfDevices[nwkid]["Ep"][tmpEp]: EPout = tmpEp cluster_frame = "01" sqn = get_and_inc_SQN(self, nwkid) cmd = "04" # Ask the Tilt Blind to go to a certain Level payload = cluster_frame + sqn + cmd + "%02x" % level raw_APS_request(self, nwkid, EPout, "0008", "0104", payload, zigate_ep=ZIGATE_EP) self.log.logging( "Profalux", "Debug", "profalux_MoveToLevelWithOnOff ++++ %s/%s Level: %s payload: %s" % (nwkid, EPout, level, payload), nwkid, )
def tuya_siren_alarm_temp(self, nwkid, min_temp_alarm, max_temp): # Enable Temp Alarm 18° <---> 33°c # Max temp Min temp # 00 23 6c02 00 04 00000021 6b02 00 04 00000012 # 00 24 7101 00 01 01 # self.log.logging( "Tuya", "Debug", "tuya_siren_alarm_min_temp - %s Min Temp: %s Max Temp: %s" % (nwkid, min_temp_alarm, max_temp) ) # determine which Endpoint EPout = "01" sqn = get_and_inc_SQN(self, nwkid) cluster_frame = "11" cmd = "00" # Command action1 = "%04x" % struct.unpack("H", struct.pack(">H", 0x026C))[0] data1 = "%08x" % max_temp action2 = "%04x" % struct.unpack("H", struct.pack(">H", 0x026B))[0] data2 = "%08x" % min_temp_alarm tuya_cmd(self, nwkid, EPout, cluster_frame, sqn, cmd, action1, data1, action2, data2)
def send_timesynchronisation(self, NwkId, srcEp, ClusterID, dstNWKID, dstEP, serial_number): # Request: cmd: 0x24 Data: 0x0008 # 0008 600d8029 600d8e39 # Request: cmd: 0x24 Data: 0x0053 # 0053 60e9ba1f 60e9d63f if NwkId not in self.ListOfDevices: return sqn = get_and_inc_SQN(self, NwkId) field1 = "0d" field2 = "80" field3 = "29" EPOCTime = datetime(1970, 1, 1) now = datetime.utcnow() UTCTime_in_sec = int((now - EPOCTime).total_seconds()) LOCALtime_in_sec = int((utc_to_local(now) - EPOCTime).total_seconds()) utctime = "%08x" % UTCTime_in_sec localtime = "%08x" % LOCALtime_in_sec self.log.logging( "Tuya", "Debug", "send_timesynchronisation - %s/%s UTC: %s Local: %s" % (NwkId, srcEp, UTCTime_in_sec, LOCALtime_in_sec), ) payload = "11" + sqn + "24" + serial_number + utctime + localtime raw_APS_request(self, NwkId, srcEp, "ef00", "0104", payload, zigate_ep=ZIGATE_EP, ackIsDisabled=False) self.log.logging("Tuya", "Debug", "send_timesynchronisation - %s/%s " % (NwkId, srcEp))
def get_group_identifiers_request(self, nwkid): cluster_frame = "19" sqn = get_and_inc_SQN(self, nwkid) command = "41" start_index = "00" cluster = "1000" ListOfEp = getListOfEpForCluster(self, nwkid, cluster) if len(ListOfEp) != 1: return payload = cluster_frame + sqn + command + start_index ep = ListOfEp[0] raw_APS_request( self, nwkid, ep, cluster, "0104", payload, zigate_ep=ZIGATE_EP, ackIsDisabled=is_ack_tobe_disabled(self, nwkid), highpriority=True, )