Help with Hue dimmer value on openhab2

I think that openhab2 hue bindings always use color channel even when dimming. So the value is hue, sat, bright, for example state = 84,55,75. I think this i a problem when i use a guide for a rule on openhab1. What i need is to compare the brightness value in a lamp with another value. How to i extract only the brightness value (75 in exemple) to a percentType?

According to the code calling (MyHue.state as HSBType).getBrightness returns a PercentType.

Thank you so much man. Your help is worth gold!

Is it also possibile to send commands in this way instead of just receiving?

for example, i got a rule for dimming down the lights:

rule "Einschlaf-Licht Test"
	Item Scenes_Wohnzimmer received command SLEEP
	if ((Hue_wohnzimmer_Lightstrip_Farbe.state as HSBType).getBrightness > 90) {
	createTimer(now.plusSeconds(5)) [sendCommand(Hue_wohnzimmer_Lightstrip_Farbe, "0,100,90")]
	if ((Hue_wohnzimmer_Lightstrip_Farbe.state as HSBType).getBrightness > 80) {
	createTimer(now.plusSeconds(10)) [sendCommand(Hue_wohnzimmer_Lightstrip_Farbe, "0,100,80")]
	if ((Hue_wohnzimmer_Lightstrip_Farbe.state as HSBType).getBrightness > 70) {
	createTimer(now.plusSeconds(15)) [sendCommand(Hue_wohnzimmer_Lightstrip_Farbe, "0,100,70")]

in the rule the color of the light is fixed but i would like to just dim the lights down so that the color doesnt change. my first idea was to do it with a dimmer item but i cant add one with the latest hue binding in paper ui…

Just sendCommand with a single number. You might need to create a PercentType out of the number.

You can send Dimmer and Switch commands to Color Items.

But this will not work very well when you use the sendCommand/postUpdate Actions. This is one of the reasons I always encourage to use the methods on the Items.



Hue_wohnzimmer_Lightstrip_Farbe.sendCommand(new PercentType(50))

thanks a lot! it works perfect!

in addition to this:
can you tell me whats the difference between using the sendcommand action and using the method or is there maybe an entry in the documentation?

1 Like