Brightness adjustment (HSBType won't keep color)

I want to extract Brightness from a HSB Type and vice-versa.
This rule works:

rule "Adjust sideboard brightness from HSB"
when
	Item TV_sideboard_Color changed
then
	val TV_sideboard_bri = (TV_sideboard_Color.state as HSBType).getBrightness()
	if(TV_sideboard_bri != TV_sideboard_Dimm.state)
	{
		TV_sideboard_Dimm.postUpdate(TV_sideboard_bri)
	} 
end 

But:
Changing only the third value of a HSB won’t work.
This was my approach:

rule "Adjust sideboard HSB from brightness"
when
	Item TV_sideboard_Dimm changed
then
	val TV_sideboard_hue = (TV_sideboard_Color.state as HSBType).getHue()
	val TV_sideboard_sat = (TV_sideboard_Color.state as HSBType).getSaturation()
	val TV_sideboard_bri = (TV_sideboard_Color.state as HSBType).getBrightness()
	if(TV_sideboard_bri != TV_sideboard_Dimm.state)
	{
		TV_sideboard_Color.postUpdate(TV_sideboard_hue,TV_sideboard_sat,TV_sideboard_bri)
	}
end 

Why am i doing this?
Using the brightness value of the DMX Binding won’t work for me.
It only fades from white to black.
So the color is lost (H/S Value of HSB)

Many Thanks :raised_hands:

You have to use

TV_sideboard_Color.sendCommand()

to send a command. .postUpdate will only change the state of the item in openHAB itself.

1 Like

Hey Udo,

Well I know what sendCommand does. But the rule above works, using postUpdate. The dimmer item changes. This is not the case using sendCommand within the second rule.

Ah, maybe you have to build strings. As you didn’t set val to Int, I guess the val is a primitive.

Thats it.
I solved it by building a string containing the HSB Values.

Thank you :slight_smile: