Closed anar4732 closed 1 year ago
@ClusterM since you added this support, can you help with this?
This might be one of the new devices mentioned in #74.
After sending a command with the app, what do the device debug logs show? What DPS are they using? These can be found in the Tuya developer portal (instructions for getting them can be found at https://www.zigbee2mqtt.io/advanced/support-new-devices/03_find_tuya_data_points.html#_7-find-your-devices )
Hi @uzlonewolf those are shown after sending a command with the app. The IDs are 1.2.3 and so on.
Thanks for that. What happens if you run:
import tinytuya
tinytuya.set_debug(toggle=True, color=False)
ir = tinytuya.Device("35217541c45bbef5a1f1", version=3.3, persist=True)
ir.set_value(3, "1IyOvEToCZQI5AkoCOgJNAjYCTwI4AlACNQJMAjkCTQI2ApsGSwKZBkkClwZMAp8GLALLBhgC0wYRAtMGEwLRBhMCbgIdAmkCGwLKBhsCagIaAsoGGgJzAhACbwIWAnICFAJvAh0CxgYdAmoCFwLMBhoCcAIUAtAGFALRBhQC0QYUAtAGFQKXnBgjCAkXAiDL")
ir.set_value(1, "send_ir")
@uzlonewolf
DEBUG:TinyTuya [1.8.0]
DEBUG:loaded=devices.json [3 devices]
DEBUG:Device '35217541c45bbef5a1f1' found in devices.json
DEBUG:Listening for device 35217541c45bbef5a1f1 on the network
DEBUG:find() received broadcast from '192.168.0.184': {'ip': '192.168.0.184', 'gwId': '35217541c45bbef5a1f1', 'active': 2, 'ability': 0, 'mode': 0, 'encrypt': True, 'productKey': 'keyf9fsmuufeywsr', 'version': '3.3'}
DEBUG:find() is returning: {'ip': '192.168.0.184', 'version': '3.3', 'id': '35217541c45bbef5a1f1', 'product_id': 'keyf9fsmuufeywsr', 'data': {'ip': '192.168.0.184', 'gwId': '35217541c45bbef5a1f1', 'active': 2, 'ability': 0, 'mode': 0, 'encrypt': True, 'productKey': 'keyf9fsmuufeywsr', 'version': '3.3'}}
DEBUG:building command 7 payload=b'{"devId":"35217541c45bbef5a1f1","uid":"35217541c45bbef5a1f1","t":"1669736185","dps":{"3":"1IyOvEToCZQI5AkoCOgJNAjYCTwI4AlACNQJMAjkCTQI2ApsGSwKZBkkClwZMAp8GLALLBhgC0wYRAtMGEwLRBhMCbgIdAmkCGwLKBhsCagIaAsoGGgJzAhACbwIWAnICFAJvAh0CxgYdAmoCFwLMBhoCcAIUAtAGFALRBhQC0QYUAtAGFQKXnBgjCAkXAiDL"}}'
DEBUG:sending payload
DEBUG:payload encrypted=b'000055aa000000010000000700000137332e330000000000000000000000008286c18de89ac00b7ddfb5d573b9d4fca92603bab7c419c3f95a4c2c092a7657a99f76692b7aebd8fbcc7ee14d8db5fe7d592a36396dd0f232d55044095a6cd40d6666b9c826beff76f702c408ff3dd3a5a7509ae3a27a13ab6bc77f7057e1e9b62c7f71b0090cea22b31587653bef9eddeb99dacfe97878f8136485446f8ebc9601141f149897d82fb45cfe97a777cdfb00a634a31e767a4d0fa281240f2628d1b345dcc7596d3d530385e718f36c9de5c484bba8980b8ff0be902dcc0add5dc011a25fc3ce18a3a5ad443b250b73dc0e5d3d9779c3c1ae61620a229091e27d8bc4e381daa7bf9cf9c3233695e30f77a3505564761d68f09c223dba1f7a102e83fcb10338f4abccd0cad74622c854a55ba7c8c7cf20543240d590372add73ee041bb7ee0000aa55'
DEBUG:received data=b'000055aa00000001000000070000000c00000000a505a9140000aa55'
DEBUG:received null payload (TuyaMessage(seqno=1, cmd=7, retcode=0, payload=b'', crc=2768611604, crc_good=True)), fetch new one - retry 0 / 5
DEBUG:building command 7 payload=b'{"devId":"35217541c45bbef5a1f1","uid":"35217541c45bbef5a1f1","t":"1669736191","dps":{"1":"send_ir"}}'
DEBUG:sending payload
DEBUG:payload encrypted=b'000055aa000000020000000700000087332e330000000000000000000000008286c18de89ac00b7ddfb5d573b9d4fca92603bab7c419c3f95a4c2c092a7657a99f76692b7aebd8fbcc7ee14d8db5fe7d592a36396dd0f232d55044095a6cd4065c583fcb201547f7cd65a36f9fadbe9d025a7eed0ae1af7b0e87c3cf63d9d53b421278a9a6f7978c8215514ac2bbaa9cf1a6840000aa55'
DEBUG:received data=b'000055aa00000002000000070000000c0000000018cfc5da0000aa55'
DEBUG:received null payload (TuyaMessage(seqno=2, cmd=7, retcode=0, payload=b'', crc=416269786, crc_good=True)), fetch new one - retry 0 / 5
DEBUG:received data=b'000055aa00000000000000080000006b00000000332e330000000000000010000000018286c18de89ac00b7ddfb5d573b9d4fca92603bab7c419c3f95a4c2c092a7657371ba5a0c5f80659b4f31e1677365d21dba163e77c54df4e162e83701fb7c894ab97ec30a23a66a4410c95ef576987c7c13fded40000aa55'
DEBUG:received message=TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b'3.3\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x01\x82\x86\xc1\x8d\xe8\x9a\xc0\x0b}\xdf\xb5\xd5s\xb9\xd4\xfc\xa9&\x03\xba\xb7\xc4\x19\xc3\xf9ZL,\t*vW7\x1b\xa5\xa0\xc5\xf8\x06Y\xb4\xf3\x1e\x16w6]!\xdb\xa1c\xe7|T\xdfN\x16.\x83p\x1f\xb7\xc8\x94\xab\x97\xec0\xa2:f\xa4A\x0c\x95\xefWi\x87\xc7', crc=3242188500, crc_good=True)
DEBUG:raw unpacked message = TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b'3.3\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x01\x82\x86\xc1\x8d\xe8\x9a\xc0\x0b}\xdf\xb5\xd5s\xb9\xd4\xfc\xa9&\x03\xba\xb7\xc4\x19\xc3\xf9ZL,\t*vW7\x1b\xa5\xa0\xc5\xf8\x06Y\xb4\xf3\x1e\x16w6]!\xdb\xa1c\xe7|T\xdfN\x16.\x83p\x1f\xb7\xc8\x94\xab\x97\xec0\xa2:f\xa4A\x0c\x95\xefWi\x87\xc7', crc=3242188500, crc_good=True)
DEBUG:decode payload=b'3.3\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x01\x82\x86\xc1\x8d\xe8\x9a\xc0\x0b}\xdf\xb5\xd5s\xb9\xd4\xfc\xa9&\x03\xba\xb7\xc4\x19\xc3\xf9ZL,\t*vW7\x1b\xa5\xa0\xc5\xf8\x06Y\xb4\xf3\x1e\x16w6]!\xdb\xa1c\xe7|T\xdfN\x16.\x83p\x1f\xb7\xc8\x94\xab\x97\xec0\xa2:f\xa4A\x0c\x95\xefWi\x87\xc7'
DEBUG:removing 3.x=b'\x82\x86\xc1\x8d\xe8\x9a\xc0\x0b}\xdf\xb5\xd5s\xb9\xd4\xfc\xa9&\x03\xba\xb7\xc4\x19\xc3\xf9ZL,\t*vW7\x1b\xa5\xa0\xc5\xf8\x06Y\xb4\xf3\x1e\x16w6]!\xdb\xa1c\xe7|T\xdfN\x16.\x83p\x1f\xb7\xc8\x94\xab\x97\xec0\xa2:f\xa4A\x0c\x95\xefWi\x87\xc7'
DEBUG:decrypting=b'\x82\x86\xc1\x8d\xe8\x9a\xc0\x0b}\xdf\xb5\xd5s\xb9\xd4\xfc\xa9&\x03\xba\xb7\xc4\x19\xc3\xf9ZL,\t*vW7\x1b\xa5\xa0\xc5\xf8\x06Y\xb4\xf3\x1e\x16w6]!\xdb\xa1c\xe7|T\xdfN\x16.\x83p\x1f\xb7\xc8\x94\xab\x97\xec0\xa2:f\xa4A\x0c\x95\xefWi\x87\xc7'
DEBUG:decrypted 3.x payload='{"devId":"35217541c45bbef5a1f1","dps":{"1":"send_ir"},"t":1669736191}'
DEBUG:payload type = <class 'str'>
DEBUG:decoded results='{"devId":"35217541c45bbef5a1f1","dps":{"1":"send_ir"},"t":1669736191}'
Did that work? If not, how about:
import tinytuya
tinytuya.set_debug(toggle=True, color=False)
ir = tinytuya.Device("35217541c45bbef5a1f1", version=3.3, persist=True)
ir.set_value(4, "01%^002001FE50AF@&%*@(")
ir.set_value(3, "020ed8000000000008001600160042015600ac05f3005807b8")
ir.set_value(1, "send_ir")
Did that work? If not, how about:
import tinytuya tinytuya.set_debug(toggle=True, color=False) ir = tinytuya.Device("35217541c45bbef5a1f1", version=3.3, persist=True) ir.set_value(4, "01%^002001FE50AF@&%*@(") ir.set_value(3, "020ed8000000000008001600160042015600ac05f3005807b8") ir.set_value(1, "send_ir")
nothing happening on the device. (no led blink too) 😟
Can you post the IDs for "Send Delay" and "Code library label"?
Better yet, can you post all of them? If you bring up the developer console before clicking on the "Device Logs" tab then the very first "list" should list all of them.
@uzlonewolf here.
Thanks for that. Try these:
import tinytuya
tinytuya.set_debug(toggle=True, color=False)
ir = tinytuya.Device("35217541c45bbef5a1f1", version=3.3, persist=True)
ir.set_value(4, "01%^002001FE50AF@&%*@(")
ir.set_value(3, "020ed8000000000008001600160042015600ac05f3005807b8")
ir.set_value(13, 0)
ir.set_value(10, 300)
ir.set_value(1, "send_ir")
or
import tinytuya
tinytuya.set_debug(toggle=True, color=False)
ir = tinytuya.Device("35217541c45bbef5a1f1", version=3.3, persist=True)
ir.set_value(4, "01%^002001FE50AF@&%*@(")
ir.set_value(3, "020ed8000000000008001600160042015600ac05f3005807b8")
ir.set_value(13, 0)
ir.set_value(10, 300)
ir.set_value(1, "send")
If neither of those work then it's going to have to wait until I have one to poke at, hopefully late tomorrow.
still not work 😟
is there a way to sniff the packages the app sends?
Yes, however it's not exactly easy unless you've done it before. You basically need to keep your phone connected to the WiFi but block all internet access (both cellular and via WiFi), sniff the WiFi packets to the device, and then decrypt them with the local key. It's not too bad if you have an environment set up to do it, but the first time will take a while to get everything set up.
Amazon says mine will be delivered later today, so expect a patch later tonight.
Well that was a lot harder than it should have been. Turns out, unlike pretty much every other device I have, IR blasters cannot be used in offline-local mode, so I was not able to sniff the traffic. They also do not send async status reports when another device tells it to transmit IR. So, I ended up taking mine to bits and plugging into the exposed headers to capture debug information in an attempt to glean something useful. (As a side note, it turns out these things use a ESP8266 chip, so Tasmota is an option if you want to go that route.) At first the logs didn't look too useful, just notes about updating DPS 1, 3, and 4:
[N]ir_lib.c:878 mode:1
[N]ir_lib.c:616 remain size:21400
[N]ir_lib.c:625 3:010ed800000000000700150040015a005600ad06580e74
[N]ir_lib.c:642 ir code type:0
[N]ir_lib.c:681 4:01$^002010E728D7@&$%@*
[N]ir_lib.c:439 getFre=38000
[N]ir_lib.c:529 start send.......
[N]ir_lib.c:583 send finish!
[N]ir_lib.c:725 remain size:23176
[N]ir_lib.c:886 MODE_IRSEND END......
But then I noticed that "remain size" line. That sure looks like a buffer for the DPS JSON, but why is it so large? Unless...
import tinytuya
tinytuya.set_debug(toggle=True, color=False)
ir = tinytuya.Device("35217541c45bbef5a1f1", version=3.3, persist=True)
payload = ir.generate_payload(tinytuya.CONTROL, {"1": "send_ir", "3":"020ed8000000000008001600160042015600ac05f3005807b8", "4":"01%^002001FE50AF@&%*@(", "10":3000, "13":0})
print( ir._send_receive(payload, getresponse=True) )
Bingo! It transmits! Quite obvious in hindsight actually. Raw sequences are similar:
import tinytuya
ir = tinytuya.Device("35217541c45bbef5a1f1", version=3.3, persist=True)
payload = ir.generate_payload(tinytuya.CONTROL, {"1": "study_key", "7":"liGiETMCqQYwAqcGOQKhBjYCSgIsAkwCNgJGAi8CTQIyAkoCLwKmBjYCowYyAqsGLwJlAhsCZQIQAmYCFQJsAg8CaAIRAmsCEQLIBhICzQYQAmYCEQJqAhECbAIQAmoCFwJmAhACxwYUAmcCEwJrAhECxgYTAskGEALHBhMCxgYSAsgGFwIgyw=="})
print( ir._send_receive(payload, getresponse=True) )
Hopefully I can get a patch submitted tomorrow.
Hi. just bought a Smart IR Remote Control Hub unable to control it with tinytuya
I can control the device with Tuya App. the led on the device blinks when sending any button with the app. But there is no response from the device nor the led blinks when trying to control it with tinytuya
python -m tinytuya scan
My Code: