Set Hue Brightness by switch

I just downloaded openhab2 last week and I have my bindings in place for the Hue, discovered my bulbs, can turn them on and change the brightness on them. What I’m trying to do is have a switch, so if value1 is clicked, sets the brightness to 30%, if value2 is clicked, sets the brightness to 80%. I currently have:
items

Dimmer Fan_Brightness “[%d %%]” {channel=“hue:0100:0017884179a3:7:brightness”}

sitemap
Switch item=Fan_Brightness_Night label=“Set Fan Brightness”

For my channel, I’ve tried adding :30 after brightness, tried =30 with quotes, without quotes. I’m sure there’s an easy answer. Currently if I can create a switch to set the birghtness, then I can build off of that. What am I missing? Thanks in advance for your help

Try something like this. It’ll show a switch item with 4 options. Selecting one triggers the rule, which determines which option you selected, and sends a corresponding command to the light brightness item.

Item

Number    Light_Brightness
Dimmer    Fan_Brightness    "[%d %%]"    {channel="hue:0100:0017884179a3:7:brightness"}

Sitemap

Switch    item=Light_Brightness    label="‌‌Scene"    mappings=[0="Off", 1="Low", 2="Normal", 3="High"]

Rule

rule "Light_Brightness Event"
when
	Item Light_Brightness received command
then
	switch receivedCommand{
		case 0:{
			Fan_Brightness.sendCommand(0)
		}
		case 1:{
			Fan_Brightness.sendCommand(30)
		}
		case 2:{
			Fan_Brightness.sendCommand(60)
		}
		case 3:{
			Fan_Brightness.sendCommand(100)
		}
	}
end

You can extend this logic into creating scenes which change a number of lights/items all at once by adding more commands under each case.

You don’t even need a rule you can directly map to dimmer values like:

Switch    item=Fan_Brightness    label="‌‌Scene"    mappings=[0="Off", 25="Low", 75="Normal", 100="High"]

Off course the rule solution is more flexible

1 Like

Thank you Paul and Harm for your quick solutions! That’s exactly what I was looking for. I knew it was simple but couldn’t figure out the syntax.