TH01CB3S Temperature and Humidity Sensor missing DP ID 2,3
Hi everyone, I have two of the TH01, one on main module v2.1.8 and the other on v2.1.12. For some reason, the v2.1.8 doesn't report all the IDs using tinytuya. Any help is welcome.
Using this code I can get the correct device status for the v2.1.12
sensor = tinytuya.Device(device["deviceid"], ip, device["localkey"], version=float(device["version"]), connection_timeout=2)
data = sensor.status()
protocol version is set to 3.4
v2.1.8: {'protocol': 4, 't': 1740820874, 'data': {'dps': {'1': 127}}, 'dps': {'1': 127}} v2.1.12: {'protocol': 4, 't': 1740820874, 'data': {'dps': {'1': 239,'2': 72,'3': 'high'}},'dps': {'1': 239,'2': 72,'3': 'high'}}
Here is the debug output for the v2.1.8 device:
DEBUG:TinyTuya [1.16.1]
DEBUG:Python 3.12.3 (main, Feb 4 2025, 14:48:35) [GCC 13.3.0] on linux
DEBUG:Using pyca/cryptography 44.0.1 for crypto, GCM is supported
DEBUG:status() entry (dev_type is default)
DEBUG:final payload_dict for 'bff38005b71079dd5earww' ('v3.4'/'default'): {1: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 7: {'command': {'protocol': 5, 't': 'int', 'data': {}}, 'command_override': 13}, 8: {'command': {'gwId': '', 'devId': ''}}, 9: {'command': {'gwId': '', 'devId': ''}}, 10: {'command': {}, 'command_overrid
e': 16}, 13: {'command': {'protocol': 5, 't': 'int', 'data': {}}}, 16: {'command': {}}, 18: {'command': {'dpId': [18, 19, 20]}}, 64: {'command': {'reqType': '', 'data': {}}}}
DEBUG:building command 10 payload=b'{}'
DEBUG:sending payload quick
DEBUG:final payload: b'0123456789abcdef'
DEBUG:payload encrypted=b'000055aa000000010000000300000044ddf0b90a6559879641a0781da9251ad9f2b5401ac8ad0e78dc3af1c88a24daff72d90be522214949587e22c8adfce64afcf52f7ae7437b6817efd6bef1d17cc00000aa55'
DEBUG:received data=b'000055aa0000c023000000040000006800000000bfd1befdc195edad5d1522a73522f49e69622e2e043602662fc5f62b84bd6706835fb5ed5cd42e15aaa4c47aa218c06df2b5401ac8ad0e78dc3af1c88a24daff48ed791cef5f9646006efb60a6f0e28896a2895b19d6eefe56b243219c9900c90000aa55'
DEBUG:decrypting=b'\xbf\xd1\xbe\xfd\xc1\x95\xed\xad]\x15"\xa75"\xf4\x9eib..\x046\x02f/\xc5\xf6+\x84\xbdg\x06\x83_\xb5\xed\\\xd4.\x15\xaa\xa4\xc4z\xa2\x18\xc0m\xf2\xb5@\x1a\xc8\xad\x0ex\xdc:\xf1\xc8\x8a$\xda\xff'
DEBUG:decrypted session key negotiation step 2 payload=b'e6ca753f8821e5a2i\xd1\xc4&\xa3\x0c\x90\xa8z\x8f\xce\xdfm\xbd\xf0\xdf\x004kX6J\xcb\x02\x8f\x91\xd9l\xf5\x8c\x0f{'
DEBUG:payload type = <class 'bytes'> len = 48
DEBUG:session local nonce: b'0123456789abcdef' remote nonce: b'e6ca753f8821e5a2'
DEBUG:sending payload quick
DEBUG:final payload: b"\x10\x87\xbf\xc7o\x17^\xb9\xfeR_\xc8\x89\xd6\xd2\x92\xfa\x1b\xb1'#o\xbfoa\xa0`\x98Pos\x9a"
DEBUG:payload encrypted=b'000055aa0000000200000005000000545b9334dd62de1a918415ffdf18dd361e4c3a15402c7c235882f241d750ff59a9f2b5401ac8ad0e78dc3af1c88a24daff261607fbb07488cd0291bb6ec0a0245960f1b466380bb635f4bd35d9721259af0000aa55'
DEBUG:Session nonce XOR'd: b'U\x07QR\x03\x00\x05Q\x00\x01SS\x06Q\x04T'
DEBUG:Session key negotiate success! session key: b'\xcbHY\x08>\xdb_/\xee\x90\xafc\xa0\x84s\xea'
DEBUG:sending payload
DEBUG:final payload: b'{}'
DEBUG:payload encrypted=b'000055aa000000030000001000000034c017aada9ef41997f306df5e5385aca6adfde3b595a7948dec60c4e577a9847e7844ee508a6fba5dd6d191ddb56810f30000aa55'
DEBUG:received data=b'000055aa0000c024000000100000004800000001b8e501b29d4bbb63bd1142a7fdf75d54fb78d800dc3338859f38a4c841abbee679e5a62e503e91b73814949457b16fc93afc5c9eecf14d549400fc737ef0866b0000aa55'
DEBUG:received message=TuyaMessage(seqno=49188, cmd=16, retcode=1, payload=b'\xb8\xe5\x01\xb2\x9dK\xbbc\xbd\x11B\xa7\xfd\xf7]T\xfbx\xd8\x00\xdc38\x85\x9f8\xa4\xc8A\xab\xbe\xe6', crc=b'y\xe5\xa6.P>\x91\xb78\x14\x94\x94W\xb1o\xc9:\xfc\\\x9e\xec\xf1MT\x94\x00\xfcs~\xf0\x86k', crc_good=True, prefix=21930, iv=None)
DEBUG:raw unpacked message = TuyaMessage(seqno=49188, cmd=16, retcode=1, payload=b'\xb8\xe5\x01\xb2\x9dK\xbbc\xbd\x11B\xa7\xfd\xf7]T\xfbx\xd8\x00\xdc38\x85\x9f8\xa4\xc8A\xab\xbe\xe6', crc=b'y\xe5\xa6.P>\x91\xb78\x14\x94\x94W\xb1o\xc9:\xfc\\\x9e\xec\xf1MT\x94\x00\xfcs~\xf0\x86k', crc_good=True, prefix=21930, iv=None)
DEBUG:decode payload=b'\xb8\xe5\x01\xb2\x9dK\xbbc\xbd\x11B\xa7\xfd\xf7]T\xfbx\xd8\x00\xdc38\x85\x9f8\xa4\xc8A\xab\xbe\xe6'
DEBUG:decrypting=b'\xb8\xe5\x01\xb2\x9dK\xbbc\xbd\x11B\xa7\xfd\xf7]T\xfbx\xd8\x00\xdc38\x85\x9f8\xa4\xc8A\xab\xbe\xe6'
DEBUG:decrypted 3.x payload=b'json obj data unvalid'
DEBUG:payload type = <class 'bytes'>
DEBUG:'data unvalid' error detected: switching to dev_type 'device22'
DEBUG:_decode_payload() failed!
DEBUG:Device22 detected and updated (default -> device22) - Update payload and try again
DEBUG:ERROR Device22 Detected: Retry Command - 908 - payload: null
DEBUG:status() received data={'Error': 'Device22 Detected: Retry Command', 'Err': '908', 'Payload': None}
DEBUG:status() rebuilding payload for device22
DEBUG:final payload_dict for 'bff38005b71079dd5earww' ('v3.4'/'device22'): {1: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 7: {'command': {'protocol': 5, 't': 'int', 'data': {}}, 'command_override': 13}, 8: {'command': {'gwId': '', 'devId': ''}}, 9: {'command': {'gwId': '', 'devId': ''}}, 10: {'command': {'devId': '', 'uid'
: '', 't': ''}, 'command_override': 13}, 13: {'command': {'protocol': 5, 't': 'int', 'data': {}}}, 16: {'command': {}}, 18: {'command': {'dpId': [18, 19, 20]}}, 64: {'command': {'reqType': '', 'data': {}}}}
DEBUG:building command 10 payload=b'{"devId":"bff38005b71079dd5earww","uid":"bff38005b71079dd5earww","t":"1740821416","dps":{"1":null}}'
DEBUG:sending payload quick
DEBUG:final payload: b'0123456789abcdef'
DEBUG:payload encrypted=b'000055aa000000040000000300000044ddf0b90a6559879641a0781da9251ad9f2b5401ac8ad0e78dc3af1c88a24daffee681d0ec77d9173152a538a9fd983ec87d6325e8b1196aba65c60b9d6f7cb1d0000aa55'
DEBUG:received data=b'000055aa0000c237000000040000006800000000ed9ad718ec641fd1ba587f890c7fdab369622e2e043602662fc5f62b84bd6706835fb5ed5cd42e15aaa4c47aa218c06df2b5401ac8ad0e78dc3af1c88a24daff8878f60260891370b5e45920f3d8ba8fe230f2e7f44954fd8ac08cf1bfe5e1010000aa55'
DEBUG:decrypting=b'\xed\x9a\xd7\x18\xecd\x1f\xd1\xbaX\x7f\x89\x0c\x7f\xda\xb3ib..\x046\x02f/\xc5\xf6+\x84\xbdg\x06\x83_\xb5\xed\\\xd4.\x15\xaa\xa4\xc4z\xa2\x18\xc0m\xf2\xb5@\x1a\xc8\xad\x0ex\xdc:\xf1\xc8\x8a$\xda\xff'
DEBUG:decrypted session key negotiation step 2 payload=b'4e2d0da5becedf07i\xd1\xc4&\xa3\x0c\x90\xa8z\x8f\xce\xdfm\xbd\xf0\xdf\x004kX6J\xcb\x02\x8f\x91\xd9l\xf5\x8c\x0f{'
DEBUG:payload type = <class 'bytes'> len = 48
DEBUG:session local nonce: b'0123456789abcdef' remote nonce: b'4e2d0da5becedf07'
DEBUG:sending payload quick
DEBUG:final payload: b'\x8e\x8f\x1d\x18\x7f\xc0\x1d\xe2\x98\xe6\xd4\n\x9a\xf5\x12\xf6\x9c"4\xeb\xe4\xd5\x89\xc6\xcd\x96$\x86\x1cG\xd4\xb8'
DEBUG:payload encrypted=b'000055aa00000005000000050000005424950275f4a5340762b65a32c910afcfacd60862fdbb5e8171a70b46bb6eecadf2b5401ac8ad0e78dc3af1c88a24daff3af9015e3cf0881ca24407cc50a8ebf18d01c40ec0c4c761ccfcacb583960abb0000aa55'
DEBUG:Session nonce XOR'd: b'\x04T\x00W\x04QW\x02Z\\\x02\x07\x07\x02UQ'
DEBUG:Session key negotiate success! session key: b'x\x05\x84Lw!\x01\x16o<\xa9YK\x8c\x02\x1a'
DEBUG:sending payload
DEBUG:final payload: b'3.4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00{"devId":"bff38005b71079dd5earww","uid":"bff38005b71079dd5earww","t":"1740821416","dps":{"1":null}}'
DEBUG:payload encrypted=b'000055aa000000060000000d000000a4206be9935fab5e85e57eaf8d59e275416cd3aeb8e9e38312fb16636477ce2488861298588814450dbf7194cd5af98b1969226d19bc6f6f53e6b1e1a01ba312df94ae01643e18ff0807f19a762237b2584355d284a697be5fec8abce712d1df467b0ac4240a53add6907156778f9550b020ad3788881519aca96db2327716b69ae16a56ede45710c3a9c587c5292
dff811811e18db2ba49f547627fdcbca957ae0000aa55'
DEBUG:received data=b'000055aa0000c2380000000800000068000000000c7165168f2d1081b4a5b74aa3a59576421a3132db110892686f2d8d1e9d715394391f13a10a19d4a7ef313d9e5cb87f265a78a5ad22b3c17c2da17701206422ed0e12f574bcb944380fb571850ce22ce78d1c99bddcffc25c3cd3fdcfc80e1a0000aa55'
DEBUG:received message=TuyaMessage(seqno=49720, cmd=8, retcode=0, payload=b'\x0cqe\x16\x8f-\x10\x81\xb4\xa5\xb7J\xa3\xa5\x95vB\x1a12\xdb\x11\x08\x92ho-\x8d\x1e\x9dqS\x949\x1f\x13\xa1\n\x19\xd4\xa7\xef1=\x9e\\\xb8\x7f&Zx\xa5\xad"\xb3\xc1|-\xa1w\x01 d"', crc=b'\xed\x0e\x12\xf5t\xbc\xb9D8\x0f\xb5q\x85\x0c\xe2,\xe7\x8d\x1c\x99\xbd\xdc\xff\xc2\
\<\xd3\xfd\xcf\xc8\x0e\x1a', crc_good=True, prefix=21930, iv=None)
DEBUG:raw unpacked message = TuyaMessage(seqno=49720, cmd=8, retcode=0, payload=b'\x0cqe\x16\x8f-\x10\x81\xb4\xa5\xb7J\xa3\xa5\x95vB\x1a12\xdb\x11\x08\x92ho-\x8d\x1e\x9dqS\x949\x1f\x13\xa1\n\x19\xd4\xa7\xef1=\x9e\\\xb8\x7f&Zx\xa5\xad"\xb3\xc1|-\xa1w\x01 d"', crc=b'\xed\x0e\x12\xf5t\xbc\xb9D8\x0f\xb5q\x85\x0c\xe2,\xe7\x8d\x1c\x99\xbd\xdc\xf
f\xc2\\<\xd3\xfd\xcf\xc8\x0e\x1a', crc_good=True, prefix=21930, iv=None)
DEBUG:decode payload=b'\x0cqe\x16\x8f-\x10\x81\xb4\xa5\xb7J\xa3\xa5\x95vB\x1a12\xdb\x11\x08\x92ho-\x8d\x1e\x9dqS\x949\x1f\x13\xa1\n\x19\xd4\xa7\xef1=\x9e\\\xb8\x7f&Zx\xa5\xad"\xb3\xc1|-\xa1w\x01 d"'
DEBUG:decrypting=b'\x0cqe\x16\x8f-\x10\x81\xb4\xa5\xb7J\xa3\xa5\x95vB\x1a12\xdb\x11\x08\x92ho-\x8d\x1e\x9dqS\x949\x1f\x13\xa1\n\x19\xd4\xa7\xef1=\x9e\\\xb8\x7f&Zx\xa5\xad"\xb3\xc1|-\xa1w\x01 d"'
DEBUG:decrypted 3.x payload=b'3.4\x00\x00\x00\x00\x00\x00\xe0\xed\x00\x00\x00\x01{"protocol":4,"t":4,"data":{"dps":{"1":122}}}'
DEBUG:payload type = <class 'bytes'>
DEBUG:removing 3.x=b'{"protocol":4,"t":4,"data":{"dps":{"1":122}}}'
DEBUG:decoded results='{"protocol":4,"t":4,"data":{"dps":{"1":122}}}'
Here is the debug output for the v2.1.12 device:
DEBUG:TinyTuya [1.16.1]
DEBUG:Python 3.12.3 (main, Feb 4 2025, 14:48:35) [GCC 13.3.0] on linux
DEBUG:Using pyca/cryptography 44.0.1 for crypto, GCM is supported
DEBUG:status() entry (dev_type is default)
DEBUG:final payload_dict for 'bffad491413e4161c7lrzs' ('v3.4'/'default'): {1: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 7: {'command': {'protocol': 5, 't': 'int', 'data': {}}, 'command_override': 13}, 8: {'command': {'gwId': '', 'devId': ''}}, 9: {'command': {'gwId': '', 'devId': ''}}, 10: {'command': {}, 'command_overrid
e': 16}, 13: {'command': {'protocol': 5, 't': 'int', 'data': {}}}, 16: {'command': {}}, 18: {'command': {'dpId': [18, 19, 20]}}, 64: {'command': {'reqType': '', 'data': {}}}}
DEBUG:building command 10 payload=b'{}'
DEBUG:sending payload quick
DEBUG:final payload: b'0123456789abcdef'
DEBUG:payload encrypted=b'000055aa000000010000000300000044761d1c80e696889a2e820f74f7b85b4d3ef35194488c2a9d543a1c3be16c41f826958a7fd5cd46d3db61e7341066e52f702bf3f83f2d054189a461fe803f9a7c0000aa55'
DEBUG:received data=b'000055aa00002cda0000000400000068000000008fd3e8e35b58583c5ebf44d5e68d94ec4b17fb6ab3d4c89f72547c4217376fa3e2f5692686205b1c5555fc16e1e0224c3ef35194488c2a9d543a1c3be16c41f81f28cf9d4a8ca9b22fc64ff1c6055f384a7967b6f52499b95ea94c019dd0c6c50000aa55'
DEBUG:decrypting=b'\x8f\xd3\xe8\xe3[XX<^\xbfD\xd5\xe6\x8d\x94\xecK\x17\xfbj\xb3\xd4\xc8\x9frT|B\x177o\xa3\xe2\xf5i&\x86 [\x1cUU\xfc\x16\xe1\xe0"L>\xf3Q\x94H\x8c*\x9dT:\x1c;\xe1lA\xf8'
DEBUG:decrypted session key negotiation step 2 payload=b'73a05d8f7f3c44b8\x88\x12\x03\xfc\xbcW\x98G\xa2\xe0\xfagJc-\xbc\x0e\xb55\xe3c\x1b\xca\xc5\xdd\xb9\x07\x9f\x89\x8b\xe8y'
DEBUG:payload type = <class 'bytes'> len = 48
DEBUG:session local nonce: b'0123456789abcdef' remote nonce: b'73a05d8f7f3c44b8'
DEBUG:sending payload quick
DEBUG:final payload: b'/]\xc5@S\x9c\t\xab\x9e\xdf2\xfc\xf9\x1e\xfe\xbb+o@\xf4\xa5\xd1\x0eY\x85\xc0n\xd0&\xe3\x8d\xff'
DEBUG:payload encrypted=b'000055aa000000020000000500000054e86512ac762baf09f66f2a7f6d9635c409311e504be6fab735fffccb482629a23ef35194488c2a9d543a1c3be16c41f85abff8f55b819eb057f90431002f9003e77675e86cf2e7b2db204e606237cde30000aa55'
DEBUG:Session nonce XOR'd: b'\x07\x02S\x03\x01Q\x0eQ\x0f_R\x01WP\x07^'
DEBUG:Session key negotiate success! session key: b'~\x9fr\x8f\x94_\xbf\xa9\x11\x9d\x02\xbd\x84\xf9\x8eF'
DEBUG:sending payload
DEBUG:final payload: b'{}'
DEBUG:payload encrypted=b'000055aa000000030000001000000034ab384619909a26abb40fde6306d673d8b2d87838ec47611a5e1091681367f7fe0a2d2c01fc9767a2f71dab59ec407b8d0000aa55'
DEBUG:received data=b'000055aa00002cdb00000010000000480000000148d59319ceb34e8d9a95b2606e67dbd15ecd10c981f42664103e8f223a2ad6e3d238406030c2bb8b6c7bbbc0e5a4905bc0cd716bcf25f74c58c9a221d5e9c8920000aa55'
DEBUG:received message=TuyaMessage(seqno=11483, cmd=16, retcode=1, payload=b'H\xd5\x93\x19\xce\xb3N\x8d\x9a\x95\xb2`ng\xdb\xd1^\xcd\x10\xc9\x81\xf4&d\x10>\x8f":*\xd6\xe3', crc=b'\xd28@`0\xc2\xbb\x8bl{\xbb\xc0\xe5\xa4\x90[\xc0\xcdqk\xcf%\xf7LX\xc9\xa2!\xd5\xe9\xc8\x92', crc_good=True, prefix=21930, iv=None)
DEBUG:raw unpacked message = TuyaMessage(seqno=11483, cmd=16, retcode=1, payload=b'H\xd5\x93\x19\xce\xb3N\x8d\x9a\x95\xb2`ng\xdb\xd1^\xcd\x10\xc9\x81\xf4&d\x10>\x8f":*\xd6\xe3', crc=b'\xd28@`0\xc2\xbb\x8bl{\xbb\xc0\xe5\xa4\x90[\xc0\xcdqk\xcf%\xf7LX\xc9\xa2!\xd5\xe9\xc8\x92', crc_good=True, prefix=21930, iv=None)
DEBUG:decode payload=b'H\xd5\x93\x19\xce\xb3N\x8d\x9a\x95\xb2`ng\xdb\xd1^\xcd\x10\xc9\x81\xf4&d\x10>\x8f":*\xd6\xe3'
DEBUG:decrypting=b'H\xd5\x93\x19\xce\xb3N\x8d\x9a\x95\xb2`ng\xdb\xd1^\xcd\x10\xc9\x81\xf4&d\x10>\x8f":*\xd6\xe3'
DEBUG:decrypted 3.x payload=b'json obj data unvalid'
DEBUG:payload type = <class 'bytes'>
DEBUG:'data unvalid' error detected: switching to dev_type 'device22'
DEBUG:_decode_payload() failed!
DEBUG:Device22 detected and updated (default -> device22) - Update payload and try again
DEBUG:ERROR Device22 Detected: Retry Command - 908 - payload: null
DEBUG:status() received data={'Error': 'Device22 Detected: Retry Command', 'Err': '908', 'Payload': None}
DEBUG:status() rebuilding payload for device22
DEBUG:final payload_dict for 'bffad491413e4161c7lrzs' ('v3.4'/'device22'): {1: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 7: {'command': {'protocol': 5, 't': 'int', 'data': {}}, 'command_override': 13}, 8: {'command': {'gwId': '', 'devId': ''}}, 9: {'command': {'gwId': '', 'devId': ''}}, 10: {'command': {'devId': '', 'uid': '', 't': ''}, 'command_override': 13}, 13: {'command': {'protocol': 5, 't': 'int', 'data': {}}}, 16: {'command': {}}, 18: {'command': {'dpId': [18, 19, 20]}}, 64: {'command': {'reqType': '', 'data': {}}}}
DEBUG:building command 10 payload=b'{"devId":"bffad491413e4161c7lrzs","uid":"bffad491413e4161c7lrzs","t":"1740821655","dps":{"1":null}}'
DEBUG:sending payload quick
DEBUG:final payload: b'0123456789abcdef'
DEBUG:payload encrypted=b'000055aa000000040000000300000044761d1c80e696889a2e820f74f7b85b4d3ef35194488c2a9d543a1c3be16c41f8fdc8a4bc62d88f20e06e46952485f25a1c3ed0a5e83fcbd57b661f009a2986ee0000aa55'
DEBUG:received data=b'000055aa00008eb600000004000000680000000023dc1422155e9796ba23b9c12393cdca4b17fb6ab3d4c89f72547c4217376fa3e2f5692686205b1c5555fc16e1e0224c3ef35194488c2a9d543a1c3be16c41f81d872bcfbd4a0c6e73a06b6387227cdf31d8c6a5d1dd7dc0257d9211faabb19e0000aa55'
DEBUG:decrypting=b'#\xdc\x14"\x15^\x97\x96\xba#\xb9\xc1#\x93\xcd\xcaK\x17\xfbj\xb3\xd4\xc8\x9frT|B\x177o\xa3\xe2\xf5i&\x86 [\x1cUU\xfc\x16\xe1\xe0"L>\xf3Q\x94H\x8c*\x9dT:\x1c;\xe1lA\xf8'
DEBUG:decrypted session key negotiation step 2 payload=b'aa88832e9265cdef\x88\x12\x03\xfc\xbcW\x98G\xa2\xe0\xfagJc-\xbc\x0e\xb55\xe3c\x1b\xca\xc5\xdd\xb9\x07\x9f\x89\x8b\xe8y'
DEBUG:payload type = <class 'bytes'> len = 48
DEBUG:session local nonce: b'0123456789abcdef' remote nonce: b'aa88832e9265cdef'
DEBUG:sending payload quick
DEBUG:final payload: b'j\xd1\xfa\x8c\xd6a.w\x1cuD{\xaakHHB\xce\n\x881\xf2\x91C}\x15$E";\xf8p'
DEBUG:payload encrypted=b'000055aa00000005000000050000005495bbd92df26c510d29084b70b66ad75b8852d4d03accf43243e11718468fbf003ef35194488c2a9d543a1c3be16c41f86bd262f1445ab4f19b3227618accd0439dfccbf08a4cb0004f07f842974dacf40000aa55'
DEBUG:Session nonce XOR'd: b'QP\n\x0b\x0c\x06\x04R\x01\x0bWW\x00\x00\x00\x00'
DEBUG:Session key negotiate success! session key: b'p2\x8c\x95h\xe5\xc8\xc6O\xb6a\xf2\x84@\xa5 '
DEBUG:sending payload
DEBUG:final payload: b'3.4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00{"devId":"bffad491413e4161c7lrzs","uid":"bffad491413e4161c7lrzs","t":"1740821655","dps":{"1":null}}'
DEBUG:payload encrypted=b'000055aa000000060000000d000000a424fb36a2ee509e2bc14cee383a4377985968a383bd0fcfc29d0c47be26996fe9905614786515988b7ff2b77e85e42f36dfca6f7cb410f030a4ce7b2011acd2b6b81ee72f25161eb15ff302d15729909a60c47aa5d391c6a6e43c25b7e402c177787d4838aee0afd75dee5d280ebd8859ec2bb647a39b1841ec50b06c0dfd3daf14bd1e4ee7baf7ba2f41820bbc2e124dd0b1e7565f77ce018d8974d0983b40000000aa55'
DEBUG:received data=b'000055aa00008eb70000000800000078000000004c1e7ac7df7ab51bedef2f74fa7c8ff3579ec3cbdaadddd4c4869a99e533571c261ba9ba2676e4dae567e7845c2c1ef8588c9246377f419315cf1ee0d448bcae3f22eb88c1927667dd2b44a2d6e5fc982e50510a912b5b0b022e3cd404b13afe8e646f3ae40022df866ceec19b3d27d30000aa55'
DEBUG:received message=TuyaMessage(seqno=36535, cmd=8, retcode=0, payload=b'L\x1ez\xc7\xdfz\xb5\x1b\xed\xef/t\xfa|\x8f\xf3W\x9e\xc3\xcb\xda\xad\xdd\xd4\xc4\x86\x9a\x99\xe53W\x1c&\x1b\xa9\xba&v\xe4\xda\xe5g\xe7\x84\\,\x1e\xf8X\x8c\x92F7\x7fA\x93\x15\xcf\x1e\xe0\xd4H\xbc\xae?"\xeb\x88\xc1\x92vg\xdd+D\xa2\xd6\xe5\xfc\x98', crc=b'.PQ\n\x91+[\x0b\x02.<\xd4\x04\xb1:\xfe\x8edo:\xe4\x00"\xdf\x86l\xee\xc1\x9b=\'\xd3', crc_good=True, prefix=21930, iv=None)
DEBUG:raw unpacked message = TuyaMessage(seqno=36535, cmd=8, retcode=0, payload=b'L\x1ez\xc7\xdfz\xb5\x1b\xed\xef/t\xfa|\x8f\xf3W\x9e\xc3\xcb\xda\xad\xdd\xd4\xc4\x86\x9a\x99\xe53W\x1c&\x1b\xa9\xba&v\xe4\xda\xe5g\xe7\x84\\,\x1e\xf8X\x8c\x92F7\x7fA\x93\x15\xcf\x1e\xe0\xd4H\xbc\xae?"\xeb\x88\xc1\x92vg\xdd+D\xa2\xd6\xe5\xfc\x98', crc=b'.PQ\n\x91+[\x0b\x02.<\xd4\x04\xb1:\xfe\x8edo:\xe4\x00"\xdf\x86l\xee\xc1\x9b=\'\xd3', crc_good=True, prefix=21930, iv=None)
DEBUG:decode payload=b'L\x1ez\xc7\xdfz\xb5\x1b\xed\xef/t\xfa|\x8f\xf3W\x9e\xc3\xcb\xda\xad\xdd\xd4\xc4\x86\x9a\x99\xe53W\x1c&\x1b\xa9\xba&v\xe4\xda\xe5g\xe7\x84\\,\x1e\xf8X\x8c\x92F7\x7fA\x93\x15\xcf\x1e\xe0\xd4H\xbc\xae?"\xeb\x88\xc1\x92vg\xdd+D\xa2\xd6\xe5\xfc\x98'
DEBUG:decrypting=b'L\x1ez\xc7\xdfz\xb5\x1b\xed\xef/t\xfa|\x8f\xf3W\x9e\xc3\xcb\xda\xad\xdd\xd4\xc4\x86\x9a\x99\xe53W\x1c&\x1b\xa9\xba&v\xe4\xda\xe5g\xe7\x84\\,\x1e\xf8X\x8c\x92F7\x7fA\x93\x15\xcf\x1e\xe0\xd4H\xbc\xae?"\xeb\x88\xc1\x92vg\xdd+D\xa2\xd6\xe5\xfc\x98'
DEBUG:decrypted 3.x payload=b'3.4\x00\x00\x00\x00\x00\x00\xf9\x86\x00\x00\x00\x01{"protocol":4,"t":3,"data":{"dps":{"1":210,"2":39,"3":"high"}}}'
DEBUG:payload type = <class 'bytes'>
DEBUG:removing 3.x=b'{"protocol":4,"t":3,"data":{"dps":{"1":210,"2":39,"3":"high"}}}'
DEBUG:decoded results='{"protocol":4,"t":3,"data":{"dps":{"1":210,"2":39,"3":"high"}}}'
Do you see the additional DPS running a monitor script like: https://github.com/jasonacox/tinytuya/blob/master/examples/monitor.py
When I run the monitor.py as is I get the following. Could you tell me why this is? What is the right way to query this device and why does it behalve so differently?
> Send Request for Status <
Received Payload: {'Error': 'Network Error: Device Unreachable', 'Err': '905', '
Payload': None}
Received error!
> Send Request for Status <
Received Payload: {'protocol': 4, 't': 3, 'data': {'dps': {'1': 170}}, 'dps': {'
1': 170}}
Received Payload: {'protocol': 4, 't': 3, 'data': {'dps': {'2': 44}}, 'dps': {'2
': 44}}
Received Payload: {'protocol': 4, 't': 3, 'data': {'dps': {'3': 'middle'}}, 'dps
': {'3': 'middle'}}
Received Payload: None
Sometimes I only get dps 2 or 3 or both together, however from looking at the cloud values, I can see temperature and humidity changing.
> Send Request for Status <
Received Payload: {'Error': 'Network Error: Device Unreachable', 'Err': '905', '
Payload': None}
Received error!
> Send Request for Status <
Received Payload: {'protocol': 4, 't': 3, 'data': {'dps': {'2': 41}}, 'dps': {'2
': 41}}
Received Payload: {'protocol': 4, 't': 4, 'data': {'dps': {'3': 'high'}}, 'dps':
{'3': 'high'}}
Received Payload: None
The device is deciding what to send you, it isn't casued by the query that tinytuya is sending. Most devices send their full DPS list when a status is requested. By running the monitor loop, you are picking up status updates that the device is sending as state changes, not just as a response to a query.
Tuya devices are cloud device primarily. They are designed to update and be controlled by the Tuya cloud. The local API is lower priority (and sometimes completely absent) and , as you saw, the experience will vary based on the firmware the manufactures uses. QC is also lacking, but mostly because the local API is unnecessary for the devices to function as sold (controlled and monitored via Cloud tools). All that means is that we have to be creative on how we manage them locally. ;)
I understand all of it and I know I could just flash another firmware and these cheap devices would be independent of the cloud. I'm really into creative ways to get data from these devices, however, I don't see tinytuya getting all the data from the device even though they are there. If I call .status() I get the first dps, if I call .receive() later I get a second, but I don't get the third dps. If I call .status() one second later, I get the third dps. So this isn't about the device just sending what has updated, this is weird behavior I would be happy to understand.
First I send a .status(), after that I call .receive() until I receive a timeout from it. Why when calling .status just a second later again, I receive another dps while this isn't due to it beeing suddenly updated.
Could you elaborate a bit so I can find a creative solution to read out all the data? As these device are only online for about 5s just randomly querying them for data is a really bad solution - especially if they respond with timeouts just in between.
I picked up a few TH02 modules in #589, and they're also v2.1.8 with the same behavior. The only difference seems to be the DPs used: TH01 uses 1/2/3 while TH02 uses 27/46/101. The script I wrote in https://github.com/jasonacox/tinytuya/issues/589#issuecomment-3038823746 should also work for these TH01 modules.