Open alexandergeiler opened 1 year ago
add debug info
pi@pi-vz-be:~/tuyapower $ python debug-test-ag.py
DEBUG:TinyTuya [1.12.11]
DEBUG:Python 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110] on linux
DEBUG:Using PyCrypto (3, 19, '0')
DEBUG:status() entry (dev_type is default)
DEBUG:final payload_dict for 'bf3941cb7c91ced1a3mgyx' ('v3.3'/'default'): {1: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 7: {'command': {'devId': '', 'uid': '', 't': ''}}, 8: {mmand': {'gwId': '', 'devId': ''}}, 9: {'command': {'gwId': '', 'devId': ''}}, 10: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 13: {'command': {'devId': '', 'uid': '', 't': ''}}6: {'command': {'devId': '', 'uid': '', 't': ''}}, 18: {'command': {'dpId': [18, 19, 20]}}, 64: {'command': {'reqType': '', 'data': {}}}}
DEBUG:building command 10 payload=b'{"gwId":"bf3941cb7c91ced1a3mgyx","devId":"bf3941cb7c91ced1a3mgyx","uid":"bf3941cb7c91ced1a3mgyx","t":"1695236032"}'
DEBUG:sending payload
DEBUG:payload encrypted=b'000055aa000000010000000a00000088b715f8535d75bae7996cedb17439baf51443a358ebc7d33986982ce952f13817d2d0977d28b9087342319769958b96e9fac12072f42cb61ab8ee3a0be8d0060821ddb80941d2c64426790c52259ef1443a358ebc7d33986982ce952f138179523d666494eee41fcf7e66cb57ebfcc752172c31949f2cf665af79809d8159df3a09d650000aa55'
DEBUG:received data=b'000055aa000000010000000a0000004c000000007392de80c50f1d37fab58e692c42142b68a77b2f1fe5aa562396587a629c565c016a3c8535929dbd2e5889548f5580bac2722cb206c722556e44c11341a1df7c86d790000aa55'
DEBUG:received message=TuyaMessage(seqno=1, cmd=10, retcode=0, payload=b's\x92\xde\x80\xc5\x0f\x1d7\xfa\xb5\x8ei,B\x14+h\xa7{/\x1f\xe5\xaaV#\x96Xzb\x9cV\\\x01j<\x855\x92\x9d\xbd.X\x89T\x8fU\x80a\xc2r,\xb2\x06\xc7"UnD\xc1\x13A\xa1\xdf|', crc=2262026617, crc_good=True, prefix=21930, iv=None)
DEBUG:raw unpacked message = TuyaMessage(seqno=1, cmd=10, retcode=0, payload=b's\x92\xde\x80\xc5\x0f\x1d7\xfa\xb5\x8ei,B\x14+h\xa7{/\x1f\xe5\xaaV#\x96Xzb\x9cV\\\x01j<\x855\x92\x9d\xbd.X\x89T\x8x80\xba\xc2r,\xb2\x06\xc7"UnD\xc1\x13A\xa1\xdf|', crc=2262026617, crc_good=True, prefix=21930, iv=None)
DEBUG:decode payload=b's\x92\xde\x80\xc5\x0f\x1d7\xfa\xb5\x8ei,B\x14+h\xa7{/\x1f\xe5\xaaV#\x96Xzb\x9cV\\\x01j<\x855\x92\x9d\xbd.X\x89T\x8fU\x80\xba\xc2r,\xb2\x06\xc7"UnD\xc1\x13A\xa1\xdf|'
DEBUG:decrypting=b's\x92\xde\x80\xc5\x0f\x1d7\xfa\xb5\x8ei,B\x14+h\xa7{/\x1f\xe5\xaaV#\x96Xzb\x9cV\\\x01j<\x855\x92\x9d\xbd.X\x89T\x8fU\x80\xba\xc2r,\xb2\x06\xc7"UnD\xc1\x13A\xa1\xdf|'
DEBUG:decrypted 3.x payload='{"dps":{"1":6585,"10":0,"16":true,"18":"111111111111"}}'
DEBUG:payload type = <class 'str'>
DEBUG:decoded results='{"dps":{"1":6585,"10":0,"16":true,"18":"111111111111"}}'
DEBUG:status() received data={'dps': {'1': 6585, '10': 0, '16': True, '18': '111111111111'}}
{'dps': {'1': 6585, '10': 0, '16': True, '18': '111111111111'}}
It seems the solution is in https://github.com/jasonacox/tinytuya/issues/55
pi@pi-vz-be:~/tuyapower $ python test2.py
input text = CRsAApUAAJY=
decoded = b'\t\x1b\x00\x02\x95\x00\x00\x96'
CRsAApUAAJY= converts to 0000100100011011000000000000001010010101000000000000000010010110
----- 3 values -----
V = 0000100100011011 = 233.1 V
I = 000000000000001010010101 = 2331 mA
P = 000000000000000010010110 = 150 W
pi@pi-vz-be:~/tuyapower $
But how can I get the payload via the plugpower.py?
Hi @alexandergeiler - good job on troubleshooting. Can you share the code you use for test2.py? Essentially you need to add that to plugpower.py to make it work. If you can think of a clean way to add this in for others using plugpower.py with this smart meter, please feel free to submit a Pull Request so we can give you credit. Otherwise, the test2.py code and/or any information on what you think we should do to edit plugpower.py would be helpful.
it´s your code :-) I just change the "text" to my value. I will have a look where I can add this in plugpower.py.
import base64
# Take one of the DPS values
text = 'CV4AAPoAAC0='
field = text.encode('ascii')
print("input text = %s" % text)
# Decode base64
z =base64.b64decode(field)
print("decoded = %r" % z)
# Convert to binary - 64 bits
zbin = "".join(["{:08b}".format(x) for x in z])
print("%s converts to %s" % (text, zbin))
# Assume 2 int values are in the 64 bits
a = zbin[:32]
b = zbin[32:]
print("----- 2 values -----")
print("a = %s (%d)" % (a,int(a, 2)))
print("b = %s (%d)" % (b,int(b, 2)))
# Assume 4 int vlaues are in the 64 bits
a = zbin[:16]
b = zbin[16:32]
c = zbin[32:48]
d = zbin[48:64]
print("----- 4 values -----")
print("a = %s (%d)" % (a,int(a, 2)))
print("b = %s (%d)" % (b,int(b, 2)))
print("c = %s (%d)" % (c,int(c, 2)))
print("d = %s (%d)" % (d,int(d, 2)))
Hi jasonacox,
I am getting again now power data (you helped me in the past already with the case https://github.com/jasonacox/tuyapower/issues/17
I have try to do the same steps again. But it is not working.
I have executed the 'python -m tinytuya wizard' command:
file: tuya-raw.json
Any idea why I do not get the power data via plugpower.py? I can see the power data in the tuya-raw.json file...