At the beginning of using OH I was using lots of hue bulbs and created lots of scenes with the hue bridge. I was looking for a solution controlling the hue scenes in OH inside rules without defining every bulb’s color, brightness etc.
The solution I found is actually quite simple and I would say it’s more like a workaround for controlling the hue scenes.
But I think it is quite usefull having an easy way especially for new OH users.
First off all you need to install node-red. If you`re using the very comfortable Openhabian, just go to the console and install it through the Openhabian Config Menu.
1. Step
Create an scene-item for example:
String hue_scenes "Szenen hue" <light>
2.Step
Open node-red and through http://openhabianpi:1880 and install the addon huemagic. It’s a very nice Addon for node-red and works like a charm. Many thanks to Foddy for that. Find more Information
Menu->Manage Palette->Install-> Search for huemagic
3.Step
Now we need some nodes for controlling the scenes:
Put in the following nodes:
Configure them as following:
For the details you can easily just import the folowing nodes:
[{"id":"5b2b2114.28912","type":"openhab2-in","z":"4968106a.aefd4","name":"","controller":"aef807de.f24a58","itemname":"hue_scenes","x":143,"y":106,"wires":[["2310c3ff.df823c"],[]]},{"id":"6b277c5e.0dad74","type":"function","z":"4968106a.aefd4","name":"Szene EIN","func":"msg.payload={\"on\":true};\nreturn msg;","outputs":1,"noerr":0,"x":495,"y":84,"wires":[["87fd07d.5a694f8"]]},{"id":"87fd07d.5a694f8","type":"hue-scene","z":"4968106a.aefd4","name":"Wz warm gedimmt","bridge":"45f0a0be.46688","sceneid":"OxpNyXa2eRJ43Tc","x":669,"y":84,"wires":[[]]},{"id":"7b9ff31a.eb105c","type":"hue-group","z":"4968106a.aefd4","name":"Wohnzimmer","bridge":"45f0a0be.46688","groupid":"1","colornamer":true,"x":649,"y":132,"wires":[[]]},{"id":"e3c0e73a.514358","type":"function","z":"4968106a.aefd4","name":"Szene AUS","func":"msg.payload={\"on\":false};\nreturn msg;","outputs":1,"noerr":0,"x":495,"y":132,"wires":[["7b9ff31a.eb105c"]]},{"id":"2310c3ff.df823c","type":"switch","z":"4968106a.aefd4","name":"Weiche","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"WZ warm gedimmt","vt":"str"},{"t":"eq","v":"aus","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":306,"y":107,"wires":[["6b277c5e.0dad74"],["e3c0e73a.514358"]]},{"id":"aef807de.f24a58","type":"openhab2-controller","z":"","name":"Openhab","protocol":"http","host":"localhost","port":"8080","path":"","username":"","password":""},{"id":"45f0a0be.46688","type":"hue-bridge","z":"","name":"Philips hue","bridge":"192.168.XXX.XXX","key":"XXXXXXXXXXXXXXXXXXXXXX","interval":"3000"}]
As you can see, my scene is called “WZ war gedimmt”, but that depends on your found scenes through the scene-node.
4.Step
Control the scenes through a rule in OH:
rule "Scene ON"
when
Item KeyFob changed
then
switch (KeyFob.state)
{
case 1.0:
hue_scenes.sendCommand("WZ warm gedimmt")
case 2.0:
hue_scenes.sendCommand("aus")
}
end
That’s it. Quite easy isn’t it?