Implement colour setting for Tuya bulbs

Currently it is not possible to do this within Apilio, but this functionality could easily be implemented and would be a great addition.

The colour (and brightness of a Tuya colour changing bulb is set by sending HSV values (hue, saturation and value [=brightness]) to the bulb as a “Colour data v2” status. Apilio currently reads this value in the form of a text string (e.g. Colour data v2: {“h”:255,“s”:500,“v”:10}) but does not allow the values to be set:

It would be great if Apilio could implement setting these colour values directly. One possible implementation would be as follows: when the bulb is selected in a logicblock action, if the device supports the “Colour data v2” status, there would be three additional settings of “colour hue” (0-360), “colour saturation” (10-1000) and “colour brightness” (10-1000). Changing any of these should not affect the current settings for the other values, so Apilio should read the current settings and only change the appropriate HSV value.

If you wanted to get more friendly, you could implement “brightness” (10-1000) separately from a “colour” entry that allowed for a range of pre-built colour settings (similar to what you get in Alexa: red/blue/green… etc). Each colour would have pre-defined hue and saturation values, though the brightness value should remain unaltered when these are set. You might also wish to set the “work mode” of the lamp to “colour” when a colour was selected.

For reference, the pre-defined colours within Alexa are set up as follows:
Red (H 0, S 1000)
Crimson (H 348, S 900)
Salmon (H 17, S 520)
Orange (H 39, S 1000)
Gold (H 50, S 1000)
Yellow (H 60, S 1000)
Green (H 120, S 1000)
Turquoise (H 174, S 710)
Cyan (H 180, S 1000)
Sky blue (H 197, S 420)
Blue (H 240, S 1000)
Purple (H 277, S 860)
Magenta (H 300, S 1000)
Pink (H 348, S 250)
Lavender (H 255, S 500)

3 Likes

Thanks for this input!
Indeed the colour_data_v2 attribute is now specified in the standard instruction set:
https://developer.tuya.com/en/docs/iot/f?id=K9i5ql3v98hn3#title-9-colour_data_v2

2 Likes

Super job @bestdevteamintheworld !

Thanks @pebneter , it would be great to see this implemented at some point! :smiley:

1 Like

Hi @pebneter ,
Your new custom commands now mean that it is possible to change light colours! Fantastic job!

The custom command to use is of the format:
{“code”:“colour_data_v2”,“value”:{“h”:0,“s”:1000,“v”:100}}

This sets the light to red (H 0, S 1000) and 10% brightness (V 100). To get the colours that I describe above, just enter the values you require for the “h” and “s” entries, and set the “v” value between 10 and 1000 for 1% to 100% brightness.

Well done!

1 Like

That :mage: @pebneter is just awesome. There, said it.

1 Like

I am going to go out on a limb and say this will only work with Tuya smart life specific bulbs. I have Ajax ZigBee lights and unless I have put the command in wrong https://prnt.sc/bydwasROs1ZE it does not work. When I select Bright and Colour data to be monitored in Apilio it does not work https://prnt.sc/dqp53AbW2oS7

1 Like

Does this now work with the fix we made?

1 Like

Not tried yet as I had got round it using scenes :slight_smile:. I will test as soon as i can :slight_smile:

1 Like