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.01k stars 177 forks source link

Timeout error when i want to switch off or on #145

Closed Foraxfox closed 2 years ago

Foraxfox commented 2 years ago

I am certainly doing something wrong. But when I try to turn my light off or on in the first example:

import tinytuya

tinytuya.set_debug(True)

d = tinytuya.OutletDevice('bff160eb468467b391pggr', '###', '###')
d.set_version(3.3)

# Get Status
data = d.status() 
print('set_status() result %r' % data)

# Set to RED Color - set_colour(r, g, b):
d.turn_off()

I manage to get the state but the light doesn't turn off or on. I have normally followed all the steps of the readme.

Futhermore, the light always responds on the application

update : I added the debug function and I have indeed an error 902

DEBUG:Exceeded tinytuya retry limit (5)
DEBUG:ERROR Timeout Waiting for Device - 902 - payload: "Check device key or version"
DEBUG:set_status received data={'Error': 'Timeout Waiting for Device', 'Err': '902', 'Payload': 'Check device key or version'}

Any help or explanation as to what is happening here would be much appreciated.

Thank you

uzlonewolf commented 2 years ago

What does the status line print? We need to know which DPS set it is using. Using BulbDevice (instead of OutletDevice) may help if it's a known bulb type.

uzlonewolf commented 2 years ago

Actually, looking though your edits you did originally post the DPS values: set_status() result {'dps': {'20': True, '21': 'white', '22': 1000, '23': 211, '24': '000003e803e8', '25': '000e0d0000000000000000c80000', '26': 0, '101': True}} DPS 20-26 means it is bulb type B, which BulbDevice should auto-detect and set for you.

Foraxfox commented 2 years ago

Thanks a lot, it works better that way :)