This post is about the basic concepts of openHAB.
In the previous posts, I’ve showed how to install and set up openHAB, but what I haven’t discussed is the idea, the basics actually, openHAB is built on.
As with anything, openHAB has principal building blocks, that everything else lies on. And there is six of them.
Things, Bindings, Channels, Items, Links and Rules.
There is actually a few more, but these are the main six, that one needs to grasp, to start work with openHAB.
Things are, like the name suggests, things. Majority of time they are actual physical things. A light bulb is a thing, and so is a tv or a diy sensor. But things aren’t only restricted to these. A thing can also be a web service, weather for example. Somewhere you can get data from about the outside world or something you can send commands to. Usually Things are actual physical things and that is the way, I think, is easiest to understand what they are.
As with different people, Things can have different languages. That is where Bindings come into play. A Binding takes the specific way a Thing talks and communicates and makes it understandable to openHAB.
A Binding is like a driver on your computer. For a new component there, you would need to install a driver, that binds the component to your existing system.
For example, Philips Hue light bulb has its own binding in openHAB, that makes it easy to send commands to the bulb, or ask, if the bulb is turned on or off.
Bindings make the way you use Things generic.
Each thing has one or more channel. You can think of a channel as a property of a thing. For example, a light bulb is a thing. Now that light bulb can have many different properties that you can either manipulate or ask the status of. On and off, brightness and colour temperature. Each of these properties is represented as a channel. On and off would be a separate channel, with input and output streams for giving commands and receiving status updates. Depending on the thing, the number of channels can be very different. A light bulb may have only these three channels, where as your tv may have 50 different ones. Each to control a different side of the thing.
Things, channels and bindings so far have been about the outside world , information coming in and going out.
The next concept though is purely virtual. And that is Items.
Items represent functionality. When there is no set number of things available, there is only 13 different items. For example, there is a switch item. Its only states can be either on or off and the only commands it can send, are on and off. Or a dateTime item, that stores, you guessed it, date and time values and doesn’t have any available commands. Items come in very handy, when writing code and creating automation systems in openHAB, because you could create proxy items, whose only purpose is to store data and treat them as variables. Alternatively, Items can be LINKED to a Channel.
When an item is linked to a channel, the channel becomes enabled and the capability of that item is available through that channel. What do I mean by that? Let go back to the light bulb example. A light bulb has a channel for on and off. If we were to link a switch item to that channel, remember a switch has only two commands available, on and off, we can send commands to that channel through that item, by setting up a routine, when the item is toggled, it sends a command to the channel, which in turn turns the bulb on or off. It might seem like a lot of work to send a simple command, but remember, a switch item is a generic item. It doesn’t know or care who this command is intended to or what thing the channel belongs to. All the dirty work is done behind the scenes and all you need to do is set up a simple send command rule.
Items can be used on their own, linked to a Channel and to switch a light for example. But lets be honest, you are not here to just switch a light. The aim of the game is to automate your home, not take a switch off a wall and put it in a smart phone. That is where rules come in.
When before I said items represent functionality, then rules create functionality. With rules, we can create routines that are based on events. These events can be triggered by outside actions, such as pressing a button, time based, system based or thing based. When a rule is triggered, and a rule always has to be triggered for it to start working, it starts a script, that performs a given task. It could be turning an output on and off, a mathematical calculation etc. You determine, what task the rule does, by writing a script for it. When using Rules, you can create sequences, that not only increase comfort, but make the whole system work together and make it intelligent.
Long story short!
So to recap everything with the light bulb example.
A light bulb is a thing. A binding takes the specific language and behaviour of the thing and makes it understandable to openhab and creates channels to represent its properties. An item is a virtual representation of functionality. By linking an item and channel, the channel becomes enabled and we can control the channel through the given item, by writing a rule.
Hope this post made any sense and helped you understand how openHAB operates.
I have made videos about every post I’ve put up at my YouTube channel smartESThouse, so go and have a look there as well. And if you like what I do, help me grow, what I do by subscribing and tuning in every week when I upload a new video and post.
In the next post I will talk about a cool feature of openhab, called the HABpanel and show you how to start creating user interfaces, to use on a touchscreen. Until then, take care and I will see you next time.