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
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"}
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.