Skip to content
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

Rework payload_dict and realign the command list to match Tuya's API #166

Merged
merged 7 commits into from
Aug 7, 2022

Conversation

uzlonewolf
Copy link
Collaborator

When I started throwing random commands at my thermostat to see what it responded to, I noticed DP_QUERY_NEW was defined as 16 but payload_dict stored it as hex byte 0f (which would be 15). The more I dug into payload_dict and generate_payload() the less I liked about how it worked, so I rewrote it ^_^ . Now it functions more like an override - if the command is not explicitly overridden (such as with device22's DP_QUERY) it simply uses the command as passed to generate_payload(), and if the json dict key "command" is not defined then it just sends everything ("command" is set to "command": {"gwId": "", "devId": "", "uid": "", "t": ""}). Technically the AP_CONFIG and DP_QUERY entries can be deleted from payload_dict completely, but for now I left them.

I also noticed the list of commands didn't really make sense. It looked like it was copy-n-pasted from the list of MCU serial commands, however those have nothing to do with the local API / TCP socket commands. So, I used the LAN protocol defines from https://github.com/tuya/tuya-iotos-embeded-sdk-wifi-ble-bk7231n/blob/master/sdk/include/lan_protocol.h and removed the invalid ones. I also added the "official" names to the comments and did some text aligning.

There are also 2 unrelated 1-liners I threw in: socket.send() is now socket.sendall(), and a copy-n-paste error in the IR Remote example was corrected.

@jasonacox jasonacox merged commit 1f30d9d into jasonacox:master Aug 7, 2022
@jasonacox
Copy link
Owner

I love this! All of these make sense and improve the project. Brilliant work! I don't see a risk of breaking the API so will release this as as a minor update, v1.6.5.

Thanks @uzlonewolf !!!

@uzlonewolf
Copy link
Collaborator Author

I'm not entirely sure how it slipped in, but it seems I inadvertently added a symbolic link to ../tinytuya under server/. Not sure if you want to keep it or remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants