leeyuentuen / localtuya

local handling for Tuya devices
GNU General Public License v3.0
72 stars 17 forks source link

3.7.0-beta12 - Unable to change status of zigbee climate device #80

Open gian72 opened 11 months ago

gian72 commented 11 months ago

Devices using 3.3 protocol worked with 3.6.7, but with 3.7.0, whereas I can see device status, I cannot change the state. Here's an example of log (working case) when I set to 13.5 degree a zigbee TRV :

3.6.7 log

``` 2023-10-21 20:50:30.549 DEBUG (MainThread) [custom_components.localtuya.common] [a4c...205] Dispatching request request_set_dp to gateway with content {'value': 135, 'dp_index': 4} 2023-10-21 20:50:30.550 DEBUG (MainThread) [custom_components.localtuya.common] [bfd...uxq] Received request request_set_dp from a4c138e2e0f44205 with content {'value': 135, 'dp_index': 4} 2023-10-21 20:50:30.551 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Sending command set (device type: type_0d) 2023-10-21 20:50:30.551 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Send payload: b'{"cid":"a4c138e2e0f44205","ctype":0,"dps":{"4":135}}' 2023-10-21 20:50:30.560 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Waiting for sequence number 8822 2023-10-21 20:50:30.572 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Dispatching message TuyaMessage(seqno=8822, cmd=13, retcode=0, payload=b'', crc=3685147939, crcpassed=True) 2023-10-21 20:50:30.573 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Dispatching sequence number 8822 2023-10-21 20:50:30.577 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Decrypted payload: {} 2023-10-21 20:50:32.604 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Sending command heartbeat (device type: type_0d) 2023-10-21 20:50:32.605 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Send payload: b'{}' 2023-10-21 20:50:32.610 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Waiting for sequence number -100 2023-10-21 20:50:32.614 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211, crcpassed=True) 2023-10-21 20:50:32.615 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Got heartbeat response 2023-10-21 20:50:32.617 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Decrypted payload: {} 2023-10-21 20:50:32.712 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Dispatching message TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b'3.3\x00\x00\x00\x00\x00\x00\x92\xef\x00\x00\x00\x01mI\xc8W\xe9\x83X\x80\xfb\x04i\xbf\x1a\xca/X\xdb\x9d\x1b"C\x19\xbf\xdc/\x8d**@\xbc/\xd4\n\x7f2R\xa5\xf2\x83\x7f\x93\x19it\xda7/\xfd\xc4\xa3\xf76k\xa5\x19\x96\xbd\x01\xb1\x0f\xb3\xf6,\x93', crc=533415723, crcpassed=True) 2023-10-21 20:50:32.713 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Got status update 2023-10-21 20:50:32.717 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Decrypted payload: {"dps":{"4":135},"cid":"a4c138e2e0f44205","t":1697914231} 2023-10-21 20:50:32.718 DEBUG (MainThread) [custom_components.localtuya.common] [bfd...uxq] Dispatching event event_status_updated to sub-device a4c138e2e0f44205 with data {'2': 'manual', '4': 135, '5': 180} 2023-10-21 20:50:32.719 DEBUG (SyncWorker_11) [custom_components.localtuya.common] [a4c...205] Received event event_status_updated from gateway with data {'2': 'manual', '4': 135, '5': 180} ```

The same action (set to 22.5), doesn't raise any error but it has not effects on device:

3.7.0-beta12 log

``` 2023-10-21 21:08:29.149 DEBUG (MainThread) [custom_components.localtuya.common] [a4c...205] Dispatching request request_set_dp to gateway with content {'value': 225, 'dp_index': 4} 2023-10-21 21:08:29.150 DEBUG (MainThread) [custom_components.localtuya.common] [bfd...uxq] Received request request_set_dp from a4c138e2e0f44205 with content {'value': 225, 'dp_index': 4} 2023-10-21 21:08:29.150 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Sending command 7 (device type: type_0d) 2023-10-21 21:08:29.151 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Sending payload: b'{"devId":"bfde06e5532b876684yuxq","uid":"bfde06e5532b876684yuxq","t":"1697915309","cid":"a4c138e2e0f44205","dps":{"4":225}}' 2023-10-21 21:08:29.153 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Dispatching sequence number 16 2023-10-21 21:08:29.153 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] payload b'\x00\x00U\xaa\x00\x00\x00\x10\x00\x00\x00\x07\x00\x00\x00\x973.3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x97z\x99\x9e\xfa\x00\x9d\xb2\xf1\xd1\xcd\x08\x16\x86\x07\x17\xfdB\xea\x98\x9d\xfeC\xd4t\xca\x1805A\xc8\xc5\x8f:\xb6A+\xbb$@`\x18D\xe4\xb9#nJ\x97\x85\xd6\xfe1\x17]R\n^\xf2\xd1\xc4\x1b\xed\x9f\x08\xfd\xbb\xf4\xfd\x0c #\x01rb\xac)\x0f\x07\xb1\xf8+\xfcmst#\x87E\x12\xda\xf3\xa5\x13\xe1:v\x05\x03q8qP\xa9]y=\xd7S3\xcf\xbc\x9bv=^\x96\xa0\xb8\xde\xa6\x8d\xbb\xcd$\x1e\xbd\xfa\x06\xf9\xa6\xef\x00\x00\xaaU' - MessagePayload(cmd=7, payload=b'{"devId":"bfde06e5532b876684yuxq","uid":"bfde06e5532b876684yuxq","t":"1697915309","cid":"a4c138e2e0f44205","dps":{"4":225}}') 2023-10-21 21:08:29.158 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Command 7 waiting for sequence number 16 2023-10-21 21:08:29.173 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Dispatching message CMD 7 TuyaMessage(seqno=16, cmd=7, retcode=0, payload=b'', crc=3432306251, crc_good=True) 2023-10-21 21:08:29.174 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Dispatching sequence number 16 2023-10-21 21:08:29.175 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] ACK received for command 7: ignoring it 2023-10-21 21:08:29.429 DEBUG (MainThread) [custom_components.localtuya] Device bfde06e5532b876684yuxq found with IP 192.168.1.43 2023-10-21 21:08:29.621 DEBUG (MainThread) [custom_components.localtuya] Device bf13fef520bb6a82864qak found with IP 192.168.1.47 2023-10-21 21:08:31.685 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b'3.3\x00\x00\x00\x00\x00\x00\x92\xf6\x00\x00\x00\x01\xf9\xd5\xb1\xe6\x99\x8e,E\x91\x84Q\xee\xaa\x19\xe6\xec\x93\xfa\xac\x1b\x82\xb2\'q\xb0)\xba,=\x8cz\xfbR\x9d\xca\x94"~\xaf\xb0\xc9\x8d\xbc\x10\xc90\xd0\x87\x051^\xf8O\xbf\xf7@\x1f\x7f\x05\xa6\x04\xe8F\xba', crc=357671071, crc_good=True) 2023-10-21 21:08:31.686 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Got status update 2023-10-21 21:08:31.691 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfd...uxq] Deciphered data = '{"dps":{"5":180},"cid":"a4c138b6da8e8bd4","t":1697915311}' 2023-10-21 21:08:31.693 DEBUG (MainThread) [custom_components.localtuya.common] [bfd...uxq] Dispatching event event_status_updated to sub-device a4c138b6da8e8bd4 with data {'2': 'manual', '3': 'opened', '4': 200, '5': 180} 2023-10-21 21:08:31.698 DEBUG (SyncWorker_7) [custom_components.localtuya.common] [a4c...bd4] Received event event_status_updated from gateway with data {'2': 'manual', '3': 'opened', '4': 200, '5': ```

alexualbu commented 9 months ago

@gian72

can you try a direct patch to the file and confirm this works? you need to change /config/custom_components/localtuya/pytuya/init.py line 225 then restart home-assistant from this COMMAND: {"devId": "", "uid": "", "t": ""}, to this COMMAND: {"uid": "", "t": ""},

image
gian72 commented 9 months ago

Hi @alexualbu, I confirm it works! Thank toy very much 👍