jasonacox / tinytuya

Python API for Tuya WiFi smart devices using a direct local area network (LAN) connection or the cloud (TuyaCloud API).
MIT License
1.03k stars 182 forks source link

general question: local http requests to tuya device? #538

Open Hans-Maulwurf opened 2 months ago

Hans-Maulwurf commented 2 months ago

Hey guys,

I'm delighted that I found tinytuya, I have a Moes Smart Wifi Dimmer and it looks (for now) that I am able to somehow control and read it via tinytuya. The more I read about tuya environment, I see openAPIs specs and wonder, if it's possible to control the device by pure local http requests. Can somebody point me to a doc or the api spec that is really working directly to the device and not to the cloud?

Hans-Maulwurf commented 2 months ago

when I'm in the tuya api explorer, I see on the right a curl command with url, e.g. https://openapi.tuyaeu.com/v2.0/cloud/thing/b...

since tuya devices offer a local api on port 6668, I wonder, how to modify this url to the local ip and send the request to the device

make-all commented 2 months ago

The curl commands are for the cloud API. The devices locally do not use http, thus the need for this library to communicate with them locally.

Hans-Maulwurf commented 2 months ago

ok, fair point

jasonacox commented 2 months ago

Hi @Hans-Maulwurf, if you want more details on the protocol (how Tuya devices are accessed via the local API), you might like this great write up by @uzlonewolf : https://github.com/jasonacox/tinytuya/discussions/260