Setup OpenHAB as home automation controller on Debian 8 (Jessie)

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:

[code language=”bash”]
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" > /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" >> /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv –keyserver keyserver.ubuntu.com –recv-keys EEA14886
apt-get update
apt-get install oracle-java8-installer
[/code]

When Java is installed, it’s time to install OpenHAB:

[code language=”bash”]
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
[/code]

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:

[code language=”bash”]
cd /etc/openhab/configurations/
sudo cp openhab_default.cfg openhab.cfg
[/code]

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:

[code language=”bash”]
sudo systemctl enable openhab
[/code]

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:

[code language=”bash”]
sudo vi /usr/share/openhab/configurations/sitemaps/default.sitemap
[/code]

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:

[code language=”bash”]
sudo vi /usr/share/openhab/configurations/items/default.items
[/code]

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.

openhab-default-interface

Adding bindings

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:

[code language=”bash”]
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
[/code]

Control from your smartphone

They also offer a nice mobile application, available on the iOS App Store or Google Play Store. You can try the application with the OpenHAB setup that you’ve just created with the demo sitemap.

ios-screens

Next..

OpenHAB has a very active user community to provide support, as well as a lot of documentation available on their GitHub Wiki pages (link to the wiki page this blogpost was based on).

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.

 

Leave a Reply

March 29, 2016

Posted In: OpenHAB, Setup

Tags:

Leave a Comment