For more than a year I’ve used Domoticz as controller for my home automation setup. It worked well, but never really as I wanted it to. Looking for a flexible, more open alternative I gave OpenHAB a try. And although it’s not as easy to start with as Domoticz, for me it’s definitely here to stay.
In my previous setup, I was running Ubuntu 14.04 on my Mac Mini. I recently changed the OS to Debian 8 (Jessie) and in the next part I’ll describe how to setup OpenHAB on Debian 8. I will also tell you how to setup the first sitemap with items and explain what those terms mean.
Install using aptitude
The most easy way is to install OpenHAB on Linux is using aptitude (apt-get command). This way you will receive the updates automatically through the apt-get update command with the rest of your system updates. Before we can install OpenHAB, we need to install one of the mayor dependency, Java 8:
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" &gt; /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" &gt;&gt; /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv –keyserver keyserver.ubuntu.com –recv-keys EEA14886
apt-get install oracle-java8-installer
When Java is installed, it’s time to install OpenHAB:
wget -qO – ‘https://bintray.com/user/downloadSubjectPublicKey?username=openhab’ | sudo apt-key add –
echo "deb http://dl.bintray.com/openhab/apt-repo stable main" | sudo tee /etc/apt/sources.list.d/openhab.list
sudo apt-get update
sudo apt-get install openhab-runtime
After the installation has completed, a configuration file has te be created. OpenHAB comes with an example configuration file, which can be used. Copy the sample file:
sudo cp openhab_default.cfg openhab.cfg
This file can be used to configure additional features for OpenHAB, like e-mail or push notifications.
If you want OpenHAB to start automatically when booting Debian, enable it to auto-boot:
sudo systemctl enable openhab
You can now view OpenHAB by visiting http://[ip]:8080/ in your browser. As the error on the screen will tell you, there is no default sitemap available, so OpenHAB has nothing to show you. This is correct, as we are going to create one in the next step.
Creating the sitemap and items
The sitemap is used to describe how the interface looks like, and which controls there will be to use. To get a quick look of what’s possible with OpenHAB, we will use the official ‘demo’ sitemap. Create a new file:
sudo vi /usr/share/openhab/configurations/sitemaps/default.sitemap
Copy the content for this file from the GitHub file ‘demo.sitemap’ and save it to the location mentioned above.
The next thing is to create the items file. In this file we assign all the different controls that can be used and define their sources on the system. This could be a http location, Philips HUE bulb, or an RFXCOM wireless device. Create a new file:
sudo vi /usr/share/openhab/configurations/items/default.items
For this file, we also copy the content from his GitHub source ‘demo.items’ and save it to the location mentioned above as well.
OpenHAB automatically checks for new versions of those files every few seconds. So in a moment, you will be able to visit the URL http://[ip]:8080/ in your browser again, and this time the default sitemap will load.
From this point, you will be able to try out a few of the features that OpenHAB has built in. The next step will be to add your own items and change the sitemap to the interface that suits your setup. To add support for external devices (Philips HUE, MQTT, Netatmo or Sonos to name a few) you can install additional ‘bindings’ as OpenHAB calls it. They can be installed using aptitude as well:
sudo apt-get install openhab-addon-binding-hue
sudo apt-get install openhab-addon-binding-mqtt
sudo apt-get install openhab-addon-binding-netatmo
sudo apt-get install openhab-addon-binding-sonos
Control from your smartphone
In the next posts, I will explain more about how I am using OpenHAB for my setup now. For example to control the LED Dimmer’s from my previous posts, or how I switch my lights automatically at sunset.
eryk March 29, 2016