-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for 3.2 protocol #168
Comments
Hi @pawel-szopinski ! Thanks for opening this issue. This is the first
|
Sure, here's one device (others produce the same output)
And the extract from snapshot.json
The only reference I found about 3.2 is in this github issue: codetheweb/tuyapi#234 |
Thanks for this! From my initial research, it seems like this was spotted in 2019 but it doesn't seem like a handler for the 3.2 protocol has been discovered or added to the main tuya projects. That seems to indicate a very low population of 3.2 devices. Can you confirm that there is no firmware update available for the device in the SmartLife or Tuya smart app? Also, based on the debug you provide, it seems to be more about decryption, but it could be that 3.2 is not using COMMAND 10. I wonder if it needs to use COMMAND 13 instead. You could try this: import tinytuya
tinytuya.set_debug(True)
d = tinytuya.OutletDevice(ID, IP, KEY, 'device22')
d.set_version(3.3)
d.set_dpsUsed({"1": None}) # This needs to be a datapoint available on the device
data = d.status()
print(data) |
There is no firmware update in the SmartLife app. However, your code solution helped. I am now getting the correct status from all my switches. Thank you so much! I am closing the issue, since it is resolved. |
That's fantastic news! That means I can add logic to use I'm going to re-open this issue to remind me to add that logic. Thanks for helping! |
@pawel-szopinski I pushed updated code with 3.2 logic. Would you be able to pull it down and test it with your devices? git clone https://github.com/jasonacox/tinytuya.git
cd tinytuya
python import tinytuya
tinytuya.set_debug(True)
d = tinytuya.OutletDevice(ID, IP, KEY)
d.set_version(3.2)
data = d.status()
print(data) And also test the scan feature (make sure you devices.json is in the same directory): python -m tinytuya snapshot |
Sure, I can help with whatever you need. The code snippet you provided works like a charm (correct JSON response), so this seems to be fixed now. However, the scan and snapshot features still produce errors. Scan:
Snapshot:
EDIT: Also, I've noticed that when I want to get status of device's second switch (dps '2') I need to use the |
Thanks @pawel-szopinski ! This is pure gold! I found the issue in both if ver == "3.3":
d.set_version(3.3)
# changed to
d.set_version(float(ver)) If you don't mind, pull the latest from github (eg. I wonder if 3.2 actually needs the import tinytuya
tinytuya.set_debug(True)
d = tinytuya.OutletDevice(ID, IP, KEY, 'device22')
d.set_version(3.3)
# d.set_dpsUsed({"1": None}) # This needs to be a datapoint available on the device
data = d.status()
print(data) If that works, I will remove set_dpsUsed() from the default device 3.2 setup. Otherwise we might be able to use dps_avail = d.detect_available_dps()
d.set_dpsUsed(dps_avail)
data = d.status()
print(data) |
It looks like the status is pulled correctly now in The second code snippet produces
Last but not least, I don't mind using
Why not have
Or, if that's not feasible, make
If that's not feasible either, the easiest way not to make users confused about |
Thanks @pawel-szopinski ! Your help on this has been awesome. I agree with you on consistency. My intent it to make 3.2 devices behave the same as "non device22" 3.1 and 3.3 devices which don't need to use I can have I just pushed an update. Can you pull the latest and try again with something like this to make sure you are seeing all DPS values now?: import tinytuya
d = tinytuya.OutletDevice(ID, IP, KEY)
d.set_version(3.2)
data = d.status()
print(data) Also check the Again, I really appreciate your help. I don't have 3.2 devices so your feedback and help to test this is gold. |
Yes! One small drawback of this approach, at least in my case, is that scripts requiring status (like, flipping a switch, where you need to pull status and then invert it) take about 10x longer - 450-500ms vs 45-50ms. I understand this is due to the way you have to handle And finally, it is I who has to thank you for this awesome library, not the other way around! Thanks to it, I don't have to talk to tuya's cloud every time I want do something as simple as flipping a light switch in my living room :) |
Haha! Thanks for the kind words, @pawel-szopinski. I love this community of home automation enthusiast. This project gets better because of the incredible contributors like you! You have a great point about the latency for the detection. I see your Pull request #169 and will merge that in. Great idea! Thanks for helping! I hope you don't mind if we ping you for 3.2 help in the future. 😉 |
@pawel-szopinski the update to support 3.2 and your PR are now live in v1.6.6. Thanks again for your help! |
Thanks for merging my PR in and thanks for the kind words as well, @jasonacox! I don't mind you pinging me at all in the future. Feel free to do so. I will try to help as best as I can :) Since we're now live with v1.6.6 I am closing this issue now. |
Hi,
I have a couple of light switches that are based on protocol version 3.2. Like this one: https://www.aliexpress.com/item/32976986321.html
Using tinytuya I can turn them on/off (works when ver set to 3.3), but I cannot get status. Here's the debug log.
Is there any chance tinytuya could support 3.2?
The text was updated successfully, but these errors were encountered: