-
Notifications
You must be signed in to change notification settings - Fork 191
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
Door lock control via cloud - mk device #541
Labels
tuya_device
Support for specific Tuya Devices
tuya_iot_cloud
Support questions for getting local key and Tuya Cloud APIs.
Comments
jasonacox
added
tuya_device
Support for specific Tuya Devices
tuya_iot_cloud
Support questions for getting local key and Tuya Cloud APIs.
labels
Oct 7, 2024
You should be able to just c = tinytuya.Cloud(...)
ticket = c.cloudrequest( '/v1.0/smart-lock/devices/bfc28e88ad23bc91f6mwgz/password-ticket' )
unlock = c.cloudrequest( '/v1.1/devices/bfc28e88ad23bc91f6mwgz/door-lock/password-free/open-door', post={'ticket_id': '...'} ) cloudrequest: def cloudrequest(self, url, action=None, post=None, query=None):
"""
Make a generic cloud request and return the results.
Args:
url: Required. The URL to fetch, i.e. "/v1.0/devices/0011223344556677/logs"
action: Optional. GET, POST, DELETE, or PUT. Defaults to GET, unless POST data is supplied.
post: Optional. POST body data. Will be fed into json.dumps() before posting.
query: Optional. A dict containing query string key/value pairs.
""" |
jasonacox
added a commit
that referenced
this issue
Oct 9, 2024
Thank you! That works. Now I want to try and make it work with tinytuya locally not via the cloud (which has just expired for me!) |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
tuya_device
Support for specific Tuya Devices
tuya_iot_cloud
Support questions for getting local key and Tuya Cloud APIs.
I'm trying to add in cloud support for this door lock device.
Device details first:
In the TUYA API I've worked out that you can trigger an unlock by the "Smart Lock Open Service" by grabbing a temporary key:
https://openapi.tuyaeu.com/v1.0/smart-lock/devices/bfc28e88ad23bc91f6mwgz/password-ticket
Which returns:
From that you can then trigger a temporary unlock using "Unlock Door Without Password" which uses the ticket_id above (8 character so in my example it's bxEhlNt2) so the unlock api call is:
https://openapi.tuyaeu.com/v1.1/devices/bfc28e88ad23bc91f6mwgz/door-lock/password-free/open-door
And the payload/data to set is {"ticket_id":"bxEhlNt2"}
What I'm struggling to work out is how to achieve this via the tinytuya cloud api commands. I've added/setup the cloud functions and can retrieve device state of the unit, etc.
How would I turn this into commands? In the example for a smart switch you would:
However, I'm unsure how to do raw api calls/queries using this library. Any pointers please?
The text was updated successfully, but these errors were encountered: