jasonacox / tinytuya

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

improve sendcommand #303

Closed Syrooo closed 1 year ago

Syrooo commented 1 year ago

Hello, I have an infrared tuya device. I tryied to control my TV with tinytuya, it did not work (smart life app is working ofc). So I look into https://iot.tuya.com/cloud/ > my app > devices > debug device > device debugging and look the API commands send by the javascript .

All of that for this little change with URI=iot-03/devices/DEVID/commands if does not work, with URI=devices/DEVID/commands it works.

I hope it will help some other persons.

Syrooo commented 1 year ago

A exemple of my local test:

from tinytuya import *

# Connect to Tuya Cloud
c = Cloud(
        apiRegion="eu", 
        apiKey="KEY", 
        apiSecret="SECRET")

# Select a Device ID to Test
id = "DEVID" #tv

# Send Command - Turn on switch
commands = {
    'commands': [
  {
    "code": "Volume-"
  }
]
}

print("Sending command...")
result = c.sendcommand(id,commands,uri='devices/')
print("Results\n:", result)
jasonacox commented 1 year ago

Thanks for this @Syrooo ! Nice addition.

Syrooo commented 1 year ago

Thanks for this @Syrooo ! Nice addition.

You are welcome

jasonacox commented 1 year ago

This change included in v1.12.1 (see https://pypi.org/project/tinytuya/1.12.1/ and https://github.com/jasonacox/tinytuya/releases/tag/v1.12.1).