Support for curtain switch
sfalvey opened this issue · 2 comments
I have a curtain switch that I have attached to a projector screen. I'm trying to work out what needs to be done to get it supported.
device.status() returns.... 'json obj data unvalid' with version 3.1 and when used with version 3.3 returns
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pytuya-7.0.4-py2.7.egg/pytuya/__init__.py", line 307, in status
result = cipher.decrypt(result, False)
File "/usr/local/lib/python2.7/dist-packages/pytuya-7.0.4-py2.7.egg/pytuya/__init__.py", line 87, in decrypt
raw = cipher.decrypt(enc)
File "/usr/lib/python2.7/dist-packages/Crypto/Cipher/blockalgo.py", line 295, in decrypt
return self._cipher.decrypt(ciphertext)
ValueError: Input strings must be a multiple of 16 in length
What information can I gather to get support for this type of switch?
I have worked out the switch does use version 3.1 and is broadcasting status updates in plain text. Here is the capture from the switch:
18:07:54.161119 IP 192.168.20.9.49155 > 255.255.255.255.6666: UDP, length 174
0x0000: ffff ffff ffff b4e6 2d1c 9319 0800 4500 ........-.....E.
0x0010: 00ca 6383 0000 ff11 82ee c0a8 1409 ffff ..c.............
0x0020: ffff c003 1a0a 00b6 93d6 0000 55aa 0000 ............U...
0x0030: 0000 0000 0000 0000 009e 0000 0000 7b22 ..............{"
0x0040: 6970 223a 2231 3932 2e31 3638 2e32 302e ip":"192.168.20.
0x0050: 3922 2c22 6777 4964 223a 2234 3634 3030 9","gwId":"46400
0x0060: 3837 3262 3465 3632 6431 6339 3331 3922 872b4e62d1c9319"
0x0070: 2c22 6163 7469 7665 223a 322c 2261 6269 ,"active":2,"abi
0x0080: 6c69 7479 223a 302c 226d 6f64 6522 3a30 lity":0,"mode":0
0x0090: 2c22 656e 6372 7970 7422 3a74 7275 652c ,"encrypt":true,
0x00a0: 2270 726f 6475 6374 4b65 7922 3a22 5474 "productKey":"Tt
0x00b0: 584b 7754 4d77 6950 7055 5257 4c4a 222c XKwTMwiPpURWLJ",
0x00c0: 2276 6572 7369 6f6e 223a 2233 2e31 227d "version":"3.1"}
0x00d0: c536 f54e 0000 aa55 .6.N...U
The 'json obj data unvalid' message is being generated by the switch in response to the status request. So it looks like its not receiving the correct form of status request perhaps?
18:07:58.860134 IP 192.168.20.25.59084 > 192.168.20.9.6668: Flags [S], seq 3516774561, win 29200, options [mss 1460,sackOK,TS val 739379010 ecr 0,nop,wscale 7], length 0
0x0000: b4e6 2d1c 9319 40a5 ef0f 4a55 0800 4500 ..-...@...JU..E.
0x0010: 003c 9578 4000 4006 fbd0 c0a8 1419 c0a8 .<.x@.@.........
0x0020: 1409 e6cc 1a0c d19d b8a1 0000 0000 a002 ................
0x0030: 7210 6e10 0000 0204 05b4 0402 080a 2c12 r.n...........,.
0x0040: 0742 0000 0000 0103 0307 .B........
18:07:58.864649 IP 192.168.20.9.6668 > 192.168.20.25.59084: Flags [S.], seq 1668697, ack 3516774562, win 5840, options [mss 1440], length 0
0x0000: 40a5 ef0f 4a55 b4e6 2d1c 9319 0800 4500 @...JU..-.....E.
0x0010: 002c 6385 0000 ff06 aed3 c0a8 1409 c0a8 .,c.............
0x0020: 1419 1a0c e6cc 0019 7659 d19d b8a2 6012 ........vY....`.
0x0030: 16d0 d65b 0000 0204 05a0 ...[......
18:07:58.864812 IP 192.168.20.25.59084 > 192.168.20.9.6668: Flags [.], ack 1, win 29200, length 0
0x0000: b4e6 2d1c 9319 40a5 ef0f 4a55 0800 4500 ..-...@...JU..E.
0x0010: 0028 9579 4000 4006 fbe3 c0a8 1419 c0a8 .(.y@.@.........
0x0020: 1409 e6cc 1a0c d19d b8a2 0019 765a 5010 ............vZP.
0x0030: 7210 92c4 0000 r.....
18:07:58.864974 IP 192.168.20.25.59084 > 192.168.20.9.6668: Flags [P.], seq 1:87, ack 1, win 29200, length 86
0x0000: b4e6 2d1c 9319 40a5 ef0f 4a55 0800 4500 ..-...@...JU..E.
0x0010: 007e 957a 4000 4006 fb8c c0a8 1419 c0a8 .~.z@.@.........
0x0020: 1409 e6cc 1a0c d19d b8a2 0019 765a 5018 ............vZP.
0x0030: 7210 0f95 0000 0000 55aa 0000 0000 0000 r.......U.......
0x0040: 000a 0000 0046 7b22 6465 7649 6422 3a22 .....F{"devId":"
0x0050: 3436 3430 3038 3732 6234 6536 3264 3163 46400872b4e62d1c
0x0060: 3933 3139 222c 2267 7749 6422 3a22 3436 9319","gwId":"46
0x0070: 3430 3038 3732 6234 6536 3264 3163 3933 400872b4e62d1c93
0x0080: 3139 227d 0cdf 3a0f 0000 aa55 19"}..:....U
18:07:58.870355 IP 192.168.20.9.6668 > 192.168.20.25.59084: Flags [P.], seq 1:50, ack 87, win 5754, length 49
0x0000: 40a5 ef0f 4a55 b4e6 2d1c 9319 0800 4500 @...JU..-.....E.
0x0010: 0059 6386 0000 ff06 aea5 c0a8 1409 c0a8 .Yc.............
0x0020: 1419 1a0c e6cc 0019 765a d19d b8f8 5018 ........vZ....P.
0x0030: 167a 8912 0000 0000 55aa 0000 0000 0000 .z......U.......
0x0040: 000a 0000 0021 0000 0001 6a73 6f6e 206f .....!....json.o
0x0050: 626a 2064 6174 6120 756e 7661 6c69 64d2 bj.data.unvalid.
0x0060: 5378 6900 00aa 55 Sxi...U
18:07:58.870507 IP 192.168.20.25.59084 > 192.168.20.9.6668: Flags [.], ack 50, win 29200, length 0
0x0000: b4e6 2d1c 9319 40a5 ef0f 4a55 0800 4500 ..-...@...JU..E.
0x0010: 0028 957b 4000 4006 fbe1 c0a8 1419 c0a8 .(.{@.@.........
0x0020: 1409 e6cc 1a0c d19d b8f8 0019 768b 5010 ............v.P.
0x0030: 7210 923d 0000 r..=..
18:07:58.870773 IP 192.168.20.25.59084 > 192.168.20.9.6668: Flags [F.], seq 87, ack 50, win 29200, length 0
0x0000: b4e6 2d1c 9319 40a5 ef0f 4a55 0800 4500 ..-...@...JU..E.
0x0010: 0028 957c 4000 4006 fbe0 c0a8 1419 c0a8 .(.|@.@.........
0x0020: 1409 e6cc 1a0c d19d b8f8 0019 768b 5011 ............v.P.
0x0030: 7210 923c 0000 r..<..
18:07:58.874585 IP 192.168.20.9.6668 > 192.168.20.25.59084: Flags [.], ack 88, win 5753, length 0
0x0000: 40a5 ef0f 4a55 b4e6 2d1c 9319 0800 4500 @...JU..-.....E.
0x0010: 0028 6387 0000 ff06 aed5 c0a8 1409 c0a8 .(c.............
0x0020: 1419 1a0c e6cc 0019 768b d19d b8f9 5010 ........v.....P.
0x0030: 1679 edd3 0000 .y....
18:07:58.874981 IP 192.168.20.9.6668 > 192.168.20.25.59084: Flags [R.], seq 50, ack 88, win 5840, length 0
0x0000: 40a5 ef0f 4a55 b4e6 2d1c 9319 0800 4500 @...JU..-.....E.
0x0010: 0028 6388 0000 ff06 aed4 c0a8 1409 c0a8 .(c.............
0x0020: 1419 1a0c e6cc 0019 768b d19d b8f9 5014 ........v.....P.
0x0030: 16d0 ed78 0000 ...x..
I found the resolution to this. It seems that 1=open 2=closed 3=stop in dps['1'], but it needs the value as a unicode string and not an integer. If you give it an int something breaks inside the switch and it cant return future status requests. The issue is documented here codetheweb/tuyapi#103