jasonacox / tinytuya

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

Plugs work perfectly, bulbs don't #411

Closed n00b12345 closed 1 year ago

n00b12345 commented 1 year ago

This is my code. It's a simple few lines of Python.

import tinytuya d = tinytuya.OutletDevice("device ID", "device IP", "device key") d.set_version(3.3) d.turn_on(switch=1)

Even though all the plugs work perfectly, none of the bulbs work. I tried debugging but what I am receiving are "DEBUG:received null payload" and "DEBUG:set_status received data=None" messages on running it.

(Also, thank you so much for creating this Tiny Tuya. It's beautiful! 👍 )

uzlonewolf commented 1 year ago

Bulbs should use tinytuya.BulbDevice(...) instead of tinytuya.OutletDevice(...). Most bulbs use DP 21 as the on/off, not 1 like outlets, which is probably why it's not working. For most common bulbs, BulbDevice(...) takes care of figuring out which DPs are needed. See https://github.com/jasonacox/tinytuya/blob/master/examples/bulb.py for a few examples of bulb-specific commands.

n00b12345 commented 1 year ago

Fantastic! That worked perfectly. Thank you so much. Really appreciate the help.