[SOLVED] Set color item to a basic color in sitemap

Hi,

I have a Z-Wave LED RGB bulb and I would like to create several buttons in the sitemap so that I can change the color of the light bulb to a small but common set of basic colors (red, yellow, green, pink, orange, blue, purple, cyan and white).
The bulb is bound to a Color item (Color Control channel), to a dimmer item to control the light intensity and to another dimmer item to control the color temperature.
I have a colorpicker element in the sitemap (linked to the Color item) but it does not work well (it is not responsive and there are big delays that make it almost useless) and I don’t want to remember the HSB values every time I want a particular color.

Is there a way to link a Color item to a fixed color in the sitemap?

Thanks in advance.

Not directly, but you can have a Number item with mappings=[1=“RED”],2=[“GREEN”],3=[“BLUE”],4=[“LIGHTBLUE”] and so on and a rule to trigger on that item, then some code like (untested !)

val String BLUE="225,80,50"
var HSBType hsb = new HSBType(BLUE)
...
bulb.sendCommand(hsb)

I beg to differ, just use a selection item like i do.

Selection item=WZL_COLOR label="Farbe" mappings=["60,100,100"="gelb","120,100,100"="grĂĽn","180,100,100"="tĂĽrkis","240,100,100"="blau","300,100,100"="lila","360,100,100"="rot"]

No rule necessary, every item accepts a string.

5 Likes

Nice one!

Cool!

It works. Thanks!
I was testing the rule, which is also a valid solution, but this is simpler.