Closed mnifakram closed 3 years ago
Are you using the OpenAPI package?
What you're sending looks right, so I think at this point you'll have to sniff traffic to debug further.
I'm using this library so I'm not sure what's the difference but I guess they all use the same Official Tuya Open API. Unless there's something else that I'm missing.
This library does not use the OpenAPI package.
The OpenAPI package uses the TuyaCloud to connect to devices while this library uses your local network to communicate.
The output that you posted however is output from the OpenAPI (specifically their Device Control endpoints)
Oh I see, you're right I'm using the OpenAPI as all my rest query are hitting https://openapi.tuyaus.com/v1.0/
. So do you think that I can't go further without sniffing?
Please note that I have no experience with this specific device (or the use of Tuya sensors in general) so all of the following is based on anecdotes and gut feeling. But I'd expect that you cannot change this variable for this device.
The OpenAPI dictates that all functions of the device are placed on the /devices/{deviceId}/functions
endpoint.
That endpoints returns an error for you - this strongly seems to indicate that you cannot update anything for this device.
The only thing you can do is get its current status - i.e. get if it's triggered, get its battery percentage and get the state of the temper alarm.
This idea is also backed by the fact that the value that you intend to change is device specific. It indicates if your phone should receive a notification when the status of the device changes - how would the API handle this if you have multiple devices?
Yeah totally understood and I'm here for a second opinion based on experience/expertise or some hints/guidance as this is my first time with Tuya in general .
I'm not sure how the API will handle multiple devices but currently I have 10 devices all of them are connected to the same account and I could set that toggle for each device separately. The only thing that is missing (and that's why I'm trying to do it using the API) is that you cannot control multiple devices with automation. I need to find a way to set them all on/off with a single click. Thank you though for the help, I do really appreciate it.
Hi There,
First thanks to all contributors for all the huge work that has been done on this library. Second thing, this not an issue with this library but it's more with Tuya and their documentation and I'm not sure where to even ask this question so my apologies if I'm bothering anyone. I have 10 PIR sensors that I want to be able to control via API instead of the app. I have managed to query devices for their information and status but I wasn't able to change their status via commands. Based on the documentation and the
status
output of the device, I can see that there's apir
function that accepts eitherpir
ornone
but trying to send this command bodyalways result to
I'm wondering what could be the right command to be able to enable and disable PIR alarm push notification like I can do from the app? The only thing that I'm able to think of, is that I have to try to intercept the HTTPS requests being sent by the app to Tuya server which may not be an easy task if they use pinning certificate.
If someone has any idea or hints that will be much appreciated.
Switch that I want to control:
/devices/{deviceId}
output:/devices/{deviceId}/status
output:/devices/{deviceId}/specifications
output:/devices/{deviceId}/functions
output: