OpenHAB

Johannes Schildgen
(Smart)²Home
Published in
5 min readDec 19, 2020

OpenHAB is an open-source home-automation software with a large set of available bindings to connect to thousands of smart-home devices. OpenHAB runs locally; not in the cloud. There are pre-installed images for a Raspberry Pi and other computers. This makes it easy to install.

The benefits of OpenHAB are:

  • Runs locally, not in the cloud; full control over all devices and data
  • Cloud service “myopenhab” can be connected to enable access from outside the local network and access from devices and services like Amazon Alexa, Google Home, and IFTTT.
  • Bring together devices from different vendors: Philips Hue, Homematic, KNX, Sonos, Ikea, Xiaomi.
  • Bindings for lights, roller shutters, switches, thermostats, temperature/humidity/weather/other sensors, robot vacuums, solar-plant inverters, chargers for electric cars, and much much more.
  • Apps and UIs for Android, iPhone, Google Chrome Browser, …

Alternatives of OpenHAB are, for example, IOBroker, Home Assistant, Apple Homekit, Homee, and Homey. They basically have similar features and benefits as listed above. In my articles, I will focus on OpenHAB, because that’s the system that I chose.

When should you not use a home-automation software?

  • You only have devices from only one vendor, e. g. only Philips Hue, or only Homematic devices, and the functionality of the official bridge and app is sufficient for your use case.
  • You have devices from different vendors, but you do not need cross-vendor interactions. Example: Your Hue devices only control Hue devices; the Roborock vacuum robot is only controlled via the Roborock app directly.

When should you use a home-automation software?

  • You want cross-vendor interactions without any limits.
  • The features that are offered by the official app are not enough for you.

When should you not use OpenHAB?

  • You do not want to run and maintain software on a Raspberry Pi in your local network.
  • You are afraid of coding, connecting to servers via SSH, and inspecting server logs.

In any other case, OpenHAB could be the perfect home-automation tool for you.

Fundamental Concepts in OpenHAB

  • Bindings: Bindings can be installed as addons within OpenHAB. Each binding connects to a specific family of smart-home devices, e.g. from one specific vendor. After a binding is installed, OpenHAB can discover things automatically. Furthermore, things can be manually added, e.g. by setting an initial configuration (IP address of a bridge, API token, username, password, …).
  • Things: A thing is either a bridge that enables further discovery of other things or a specific device like a light bulp or a humidity sensor. Each thing typically offers multiple channels. E.g., a light bulp can have one channel to control the brightness, and one for controlling the color temperature.
  • Items: An item has a data type (Switch, Number, String, …) and is typically linked to a specific channel of a thing. E.g., you can create an item of type Number that is linked to the brightness channel of a lightbulp.
  • Sitemaps: By designing a Sitemap, you can configure how the OpenHAB app should look like. You can add switches, sliders, texts, and much more, to control and inspect states of Items.
  • Rules: You can define rules, by specifying an event, and an action that should be executed when the given event happens. An example: Each time when the state of the Item Humidity_Cellar changed and it is higher than 60, then a dehumidifier should be turned on.
  • Persistence: OpenHAB offers multiple persistence services to store the current and historical states of items into a data store, e.g. a relational database, a time-series database, or a map. You can configure, which items’ states should be persisted how often and under which persistence service. This makes it possible to recover the items state after a system crash, access historical state values from items, and generate charts.

History of OpenHAB

  • OpenHAB 1: In the first version of OpenHAB, everything was configured within files. Things were configured by adding rows into *.things files into the OpenHAB configuration folder, analogously for items, sitemaps, and rules. There was no admin webinterface. For each change, you needed to connect to the OpenHAB server, e.g. a Raspberry Pi, via SSH.
  • OpenHAB 2: A user interface PaperUI was added which allows for adding things and items directly in the web browser. It is still possible to also use files, but the stuff you configure within files are not visible in PaperUI and vice versa. The recommendation is to add Things by using PaperUI and define items and the rest via files.
  • OpenHAB 3: PaperUI is removed. As a replacement, the MainUI is added. With this UI, nearly everything can be configured. But there are still some parts where you have to connect via SSH and apply changes in files, e.g. for configuring persistence and for inspecting logs.

As you can see, OpenHAB changed a lot over time. This can be confusing when you read documentation, articles, questions and answers about OpenHAB on the web. These texts often are related to a previous version of OpenHAB. As OpenHAB is backward compatible and still supports files, it can be confusing mixing concepts from different versions.

In OpenHAB 3, a few more concepts were introduced:

  • Models: Models enable tree-based groupings of items. The elements in the tree can be locations, equipments, and points. Example: The location “Living room” consists of two equipments “Light” and “Heating”. The “Heating” equipment has multiple points: “Actual Temperature” and “Set Temperature”.
  • Pages: In OpenHAB 2, there were Sitemaps which are shown using the user interface BasicUI. Other user interfaces like HABPanel, HABmin, and ClassicUI could also be used. They all access and control the states of items. OpenHAB 3 adds more ways to define custom user interfaces, like charts, floor plans, or layouts.
  • Scripts: Scripts are like rules, but they only specify an action, no event. Scripts can be manually run, and they can be run via other rules and scripts.

It is impossible to understand all concepts of OpenHAB by just reading this article. It is neccessary to try out as much as possible, use search engines, and read the documentation.

OpenHAB is not simple, but powerful. I tried other home-automation tools like Home Assistant because OpenHAB is very complex to understand and also to use. But I always came back to OpenHAB, because of its endless possibilities. With all other home-automation tools that I tried out, I came to their limits at some point. One example: In many tools, you click through an assistant to create rules. This is easy to use for people without programming skills, but very limited. In OpenHAB 3, you can use JavaScript, Groovy, and other languages to develop rules. This makes it possible to do everything! In another article, I will explain how to automatically turn on the light smoothly, 20 minutes before the Amazon Echo alarm rings. I could not figure out how to do this in another platform as OpenHAB.

--

--