It might be a bit of a headache at first to get up to speed with openhab if you're not too familiar with coding. I'll try and explain the fundamentals before expanding on the capabilities of the server software.
To break it down, openhab has four main coding file systems that all link with each other. They are Things, Items, Sitemaps and Rules.
Rules are probably more for the advanced automation setups so I'll stick to the first three to be able to hit the ground running. First of all, you'll need a compatible IDE for creating your code. This is essential as none of my code worked until I downloaded visual studio code from here. Visual studio code has a specific add on for openhabian compatibility. Once you've downloaded and set visual studio code then you need to begin with defining your 'Things'.
There are a few ways of doing this so I'll begin with the easy route. You need to install bindings for your smart devices. It's easiest to start with the paper UI. Go to addons and search for bindings. I started with the network binding, tradfri binding and the C-Bus bindings.
If you click on the binding itself it will open up a page explaining the different code for the things, items and sitemaps of that specific binding/smart device. I found it a great help to just copy and paste the code and then create individual things, items and sitemaps for my tradfri lights to experiment with setting them up.
Here are the demo things, items and sitemap codes for the Tradfri lights:
demo.things:
Bridge tradfri:gateway:mygateway [ host="192.168.0.177", code="EHPW5rIJKyXFgjH3" ] {
0100 myDimmableBulb "My Dimmable Bulb" [ id=65537 ]
0220 myColorTempBulb "My Color Temp Bulb" [ id=65538 ]
0210 myColorBulb "My Color Bulb" [ id=65539 ]
0830 myRemoteControl "My Remote Control" [ id=65545 ]
0010 myControlOutlet "My Control Outlet" [ id=65542 ]
0202 myBlinds "My Blinds" [ id=65547 ]
}
demo.items:
Dimmer Light1 { channel="tradfri:0100:mygateway:myDimmableBulb:brightness" }
Dimmer Light2_Brightness { channel="tradfri:0220:mygateway:myColorTempBulb:brightness" }
Dimmer Light2_ColorTemperature { channel="tradfri:0220:mygateway:myColorTempBulb:color_temperature" }
Color ColorLight { channel="tradfri:0210:mygateway:myColorBulb:color" }
Number RemoteControlBatteryLevel { channel="tradfri:0830:mygateway:myRemoteControl:battery_level" }
Switch RemoteControlBatteryLow { channel="tradfri:0830:mygateway:myRemoteControl:battery_low" }
Switch ControlOutlet { channel="tradfri:0010:mygateway:myControlOutlet:power" }
Rollershutter BlindPosition { channel="tradfri:0202:mygateway:myBlinds:position" }
demo.sitemap:
sitemap demo label="Main Menu"
{
Frame {
Slider item=Light1 label="Light1 Brightness [%.1f %%]"
Slider item=Light2_Brightness label="Light2 Brightness [%.1f %%]"
Slider item=Light2_ColorTemperature label="Light2 Color Temperature [%.1f %%]"
Colorpicker item=ColorLight label="Color"
Text item=RemoteControlBatteryLevel label="Battery Level [%d %%]"
Switch item=RemoteControlBatteryLow label="Battery Low Warning"
Switch item=ControlOutlet label="Power Switch"
Switch item=BlindPosition label="Blind Position [%d]"
}
}
I have two colour bulbs that I want to be able to switch on and off, dim and change colour. So after a bit of playing around with the code my three things, items and sitemap codes looked like this:
Bridge tradfri:gateway:mygateway [ host="192.168.x.x", code="xxxxxxxxxxxx" ] {
0210 myColorBulbLiving "Living Shelf" [ id=65537 ]
0210 myColorBulbBedroom "Bedroom" [ id=65540 ]
0830 myLivingRemote "My Living Remote" [ id=65536 ]
0830 myBedroomRemote "My Bedroom Remote" [ id=65539 ]
}
Dimmer LivingLight { channel="tradfri:0210:mygateway:65537:brightness" }
Dimmer BedroomLight { channel="tradfri:0210:mygateway:65540:brightness" }
Color myColorBulbLiving { channel="tradfri:0210:mygateway:65537:color" }
Color myColorBulbBedroom { channel="tradfri:0210:mygateway:65540:color" }
Number myLivingRemoteBatteryLevel { channel="tradfri:0830:mygateway:65536:battery_level" }
Number myBedroomRemoteBatteryLevel { channel="tradfri:0830:mygateway:65539:battery_level" }
Switch myLivingRemoteBatteryLow { channel="tradfri:0830:mygateway:65536:battery_low" }
Switch myBedroomRemoteBatteryLow { channel="tradfri:0830:mygateway:65539:battery_low" }
Switch myLivingRemoteControlOutlet { channel="tradfri:0010:mygateway:65536:power" }
Switch myBedroomRemoteControlOutlet { channel="tradfri:0010:mygateway:65539:power" }
sitemap demo label="Main Menu"
{
Frame {
Slider item=myColorBulbLiving label="Living Room Brightness [%.1f %%]"
Slider item=myColorBulbBedroom label="Bedroom Brightness [%.1f %%]"
Colorpicker item=myColorBulbLiving label="Color"
Colorpicker item=myColorBulbBedroom label="Color"
Text item=myLivingRemoteBatteryLevel label="Battery Level [%d %%]"
Text item=myBedroomRemoteBatteryLevel label="Battery Level [%d %%]"
Switch item=myLivingRemoteBatteryLow label="Battery Low Warning"
Switch item=myBedroomRemoteBatteryLow label="Battery Low Warning"
Switch item=myLivingRemoteControlOutlet label="Power Switch"
Switch item=myBedroomRemoteControlOutlet label="Power Switch"
}
}
In order for the openhab system to recognise you ikea gateway you have to type in your gateway IP address and the code written on the back of your gateway into the things file as written above.
Once you've worked out which elements you want in your sitemap you can then go back to your openhab server ui and test it out. Mine looks like this:
There are various different ways of setting up the sitemap, and you can also tweak the icons and switches etc. Far too many things to go into without a video here. Anyway, leave your comments and questions and I'll try my best to help you out.
0 Comments