How to set color for Hue lamp in a rule?

Hello everyone,

I am testing how to set values for Hue-Lights. I can switch it on, but I really do not understand how to set the values, like color or brightness.

This works just fine:

rule "test1"
	when
		Item door_entrance changed from CLOSED to OPEN
	then
		sendCommand(Hue_Bar_left_color,ON)
	end

This does not work:

rule "test2"
    	when
    		Item door_entrance changed from OPEN to CLOSED
    	then
    		sendCommand(Hue_Bar_left_color,HSBType::RED)
    	end

This one does not either: (Reference: http://docs.openhab.org/addons/bindings/hue1/readme.html#prerequisites)

rule "test3"
	when
		Item door_entrance changed from OPEN to CLOSED
	then
			var DecimalType hue = new DecimalType(240) // 0-360; 0=red, 120=green, 240=blue, 360=red(again)
			var PercentType sat = new PercentType(100) // 0-100
			var PercentType bright = new PercentType(100) // 0-100
			var HSBType light = new HSBType(hue,sat,bright)
		sendCommand(Hue_Bar_left_color, light)
	end

Could anyone explain the correct coding?

Thanks and best regards

1 Like

Well, okay. In fact they do work.

I was just confused about the Eclipse SmartHome Designer throwing an error for the code.

Sorry. :blush:

1 Like