tinytuya icon indicating copy to clipboard operation
tinytuya copied to clipboard

Invalid JSON Response from Device / json obj data unvalid

Open Markourai opened this issue 2 months ago • 2 comments

Description I'm trying to add and use my solar inverter with tinytuya. The scan is ok but when I try to retrieve the device status, I've got an error.

Environment

TinyTuya version: 1.17.4
Python version: 3.13.5
OS: debian (Trixie)
Device firmware version: 3.5
Local IP: 192.168.1.216
Target device IP: 192.168.1.204

Thank you for your help.

Debug logs from CLI

DEBUG:TinyTuya [1.17.4]
DEBUG:Python 3.13.5 (main, Jun 25 2025, 18:55:22) [GCC 14.2.0] on linux
DEBUG:Using pyca/cryptography 46.0.3 for crypto, GCM is supported
DEBUG:status() entry (dev_type is default)
DEBUG:final payload_dict for 'bf5d8a7fc02e58d813zrkp' ('v3.5'/'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_override': 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 [2] encrypted=b'00006699000000000001000000030000002c303132333435363738396162d853fd029f72115bbd9162f4f6a7852329c7813c56c9c440a834e0e7c1d68e4e00009966'
DEBUG:received data=b'0000669900000000f21500000004000000508f0bb2d007340488c64b515aca748f92472c6b25d58e6d424cc25f1c7028b1a9b84d175851a2238f263f9da2436bdb7d128be7866861bf513571361846084f7120c6f717df60f1e12864f90b7854502d00009966'
DEBUG:decrypted session key negotiation step 2 payload=b'3202215b187bf9e4\xeeRxL\xe2*\xd1\xbat\xadK\x97\xe7\xf1\xf4\x9ceh,\xff\xe7x:\x1c\r[\xeez\xc2\xab\xa1f'
DEBUG:payload type = <class 'bytes'> len = 48
DEBUG:session local nonce: b'0123456789abcdef' remote nonce: b'3202215b187bf9e4'
DEBUG:sending payload quick
DEBUG:final payload: b'\x979S\x1aW\x0fn\xe5xLHK\xa2\x02\x02S\xa4\xa6\xb0\x91\xebC9\x83\xce \xd7\x0eb\x07}\x9c'
DEBUG:payload [3] encrypted=b'00006699000000000002000000050000003c3031323334353637383961627f5b9c2bfc484989fde44bdd37c1e216071abf82df4642b5cc011accb0670a084bd6708cfce815962bf12cd6480a92c000009966'
DEBUG:Session nonce XOR'd: b'\x03\x03\x02\x01\x06\x04\x03U\t\x01V\x00\x05]\x00R'
DEBUG:Session IV: b'0123456789ab'
DEBUG:Session key negotiate success! session key: b'\xeba\xcd0\xadC$9\x8c\xa9U\x96\x90\x9e\xe0\x17'
DEBUG:sending payload
DEBUG:final payload: b'{}'
DEBUG:payload [4] encrypted=b'00006699000000000003000000100000001e303132333435363738396162d52718d0bc167524009d6768ce0ffcad64ba00009966'
DEBUG:received data=b'0000669900000000f21600000010000000350f5c15da38c0f3cad3b93e0272ae9b66dd8feb12ee40b11b540c644be2230c4c6053ca917acfcd4a69eb4b45ec12ffc5a411a6f3f200009966'
DEBUG:received message=TuyaMessage(seqno=61974, cmd=16, retcode=16777216, payload=b'json obj data unvalid', crc=b'\xcf\xcdJi\xebKE\xec\x12\xff\xc5\xa4\x11\xa6\xf3\xf2', crc_good=True, prefix=26265, iv=b'\x0f\\\x15\xda8\xc0\xf3\xca\xd3\xb9>\x02')
DEBUG:raw unpacked message = TuyaMessage(seqno=61974, cmd=16, retcode=16777216, payload=b'json obj data unvalid', crc=b'\xcf\xcdJi\xebKE\xec\x12\xff\xc5\xa4\x11\xa6\xf3\xf2', crc_good=True, prefix=26265, iv=b'\x0f\\\x15\xda8\xc0\xf3\xca\xd3\xb9>\x02')
DEBUG:decode payload=b'json obj data unvalid'
DEBUG:decoded results='json obj data unvalid'
DEBUG:ERROR Invalid JSON Response from Device - 900 - payload: "json obj data unvalid"
DEBUG:status() received data={'Error': 'Invalid JSON Response from Device', 'Err': '900', 'Payload': 'json obj data unvalid', 'invalid_json': 'json obj data unvalid'}

Markourai avatar Nov 05 '25 08:11 Markourai

Some v3.5 devices do not respond to status(). They only broadcast async DP updates (ref: https://github.com/jasonacox/tinytuya/issues/597 https://github.com/jasonacox/tinytuya/issues/589).

Try a monitor script:

https://github.com/jasonacox/tinytuya/blob/master/examples/monitor.py

Or try the script (or simliar) to what @uzlonewolf wrote here: https://github.com/jasonacox/tinytuya/issues/589#issuecomment-3038823746

jasonacox avatar Nov 06 '25 05:11 jasonacox

When you say "the scan is ok" does that mean it returned the status, or only that it found the device?

uzlonewolf avatar Nov 13 '25 07:11 uzlonewolf