Closed MandolinMicke closed 2 years ago
Hi @MandolinMicke ! Thanks for this note. The way TinyTuya detects color capability is by looking for the DPS key for colour value (DPS 24 for a Bulb type B like you have) when set_version()
is called. If you notice above, for the two different sessions your bulb is sending back a different status:
# First session - doesn't work
DEBUG:status() received data={'dps': {'21': 'colour'}}
# Second session - works
DEBUG:status() received data={'dps': {'21': 'colour', '24': '015203e803e8'}}
DPS key 21 is for mode and it shows 'colour' indicating the mode the bulb is in at the moment, so I know that seems confusing, but key 24 is the actual value for the color it should be displaying. TinyTuya logic is designed to look for that since the value for 21 can be other values (e.g. 'white', 'scene', 'music').
I don't know why your Smartbulb is not consistently sending the 24
key. I haven't seen that before. In any case, that is causing the logic in TinyTuya to assume that color cannot be set on the device . The good news is that there is a workaround. You can FORCE it to think the bulb has color capability by doing something like this:
import tinytuya
tinytuya.set_debug(True)
d = tinytuya.BulbDevice(XXX,XXX,XXX)
d.set_version(3.3)
d.has_colour = True # Force color mode capability
#d.has_brightness = True # Force brightness capability
#d.has_colourtemp = True # Force color temp capability
d.set_socketPersistent(True) # Helps when you make multiple calls to the bulb
print(d.set_mode('colour'))
print(d.set_colour(200,100,0))
As you can see, you can also force brightness and colourtemp capabilities. You mention issues with scene as well. Can you elaborate on that one? There isn't any logic in TinyTuya to detect scene capability but perhaps it is something else?
well, i had issues with scene, but it might be my fault aswell.. (cant really try again since i can't replicate the issue on demand). But thanks for the tip about the force options! Will add that to my code :)
Hi, thanks for the package, nice and easy to use. I have experienced some strange behavior that would be nice to sort out.
Short description: Started with this a couple of weeks ago, and got everything to work as I wanted, tried it out today again and got a very strange behavior.
A very simple script
From this I get something like this:
However it is a RGB bulb and (it has been working before)
What makes it even stranger is that if I start the "Smart Life" app and change the color of the bulb, then it works as it should?
Any idea why or how this is happening? (want to avoid this in the future)
Note: similar behavior was experienced with scene and brightness aswell.