Skip to content
Advertisements

Turn your Raspberry Pi into a Smart Home Hub with openHAB

As many of you will know I use Raspberry Pi’s for a lot of things around my smart house, except for use one to actually run my smart home. I have tried Home Assistant on a Raspberry Pi in the past and even tried it again recently running in a Docker Container but I have always ended up abandoning the project. Well, today I am trying a new project this time with openHAB running in a Docker Container on my Raspberry Pi that runs Pi-hole. As I have written many times in the past I am a fan of Docker and its ability to let a user run countless numbers of services on one machine. This can be especially helpful on a Raspberry Pi because let’s be honest there is no shortage of fun and cool projects you can do with a Raspberry Pi. Let’s take a walk through what openHAB is and how to get it set up on your Raspberry Pi.

While researching Raspberry Pi based home automation ecosystems looking for something that I might stick out longer than Home Assistant I came across openHAB. Now I had heard of openHAB before but never really looked into it too much for one reason or another but this time something was different and I decided to look into it. So what is openHAB? Well according to there website “openHAB is a vendor and technology  agnostic open source automation software for your home.” That’s great but what does it mean? It means that openHAB (like Home Assistant) is the software backbone of your home automation system running on a device such as a Raspberry Pi. Being vendor and technology agnostic means that openHAB is not back by nor are they backing any device, service or technology but yet open to any that can be developed for in openHAB. With openHAB up and running on your Raspberry Pi, you have a complete user customizable experience in front to you that can run locally (unless you are connected cloud-based devices) and give you the type of flexibility and tweakability that most of us home automation geeks require.

Assuming you already have a Raspberry Pi set up and have Docker running on it (if you don’t see my previous posts on the topic) set up of openHAB is a breeze, just follow the steps below:

  1. From the Raspbian Desktop launch Terminal
  2. From Terminal run to create the openHAB user group and assign your user to it:
  • sudo useradd -r -s /sbin/nologin openhab
  • sudo usermod -a -G openhab <username>
  1. Next, run the following commands from the terminal to create the required directories:
  • sudo mkdir /opt/openhab051818_1941_InstallingM6.png
  • sudo mkdir /opt/openhab/conf
  • sudo mkdir /opt/openhab/userdata
  • sudo mkdir /opt/openhab/addons
  • sudo chown -R openhab:openhab /opt/openhab
  1. Now before we run the Docker Container we need to get our User_ID and Group_ID by running the following command in Terminal and writing down these two numbers:
  • id openhab
  1. From a web browser go to https://hub.docker.com/r/openhab/openhab/ and make note of the version number of the latest stable build of openHAB.
  2. Now its time to run the Docker Container, use the below command in Terminal inserting the the User_ID, Group_ID and openHAB Version we previously gathered.
  • docker run \
    –name openhab \
    –net=host \
    –tty \
    -v /etc/localtime:/etc/localtime:ro \
    -v /etc/timezone:/etc/timezone:ro \
    -v /opt/openhab/conf:/openhab/conf \
    -v /opt/openhab/userdata:/openhab/userdata \
    -v /opt/openhab/addons:/openhab/addons\
    -d \
    -e USER_ID=<User_ID> \
    -e GROUP_ID=<Group_ID> \
    –restart=always \
    openhab/openhab:<version>-armhf-debian

That’s it openHAB is now running in a Docker Container on your Raspberry Pi. all you have to do now is from a web browser navigate to http://<ip_address_of_pi&gt;:8080 and you will be greeted with the openHAB setup UI. In my opinion, this is where openHAB is superior to Home Assistant because you are given a simple to use graphical interface by which to set up your system. You will first be prompted to pick a package from Simple, Standard, Expert and Demo with Standard being the recommended so we will pick that. After that, you will pick a UI with Paper UI being the one you should start with as it is the easiest to get your devices into.

Once you are through the basic set up and in the Paper UI you are ready to start adding things. The majority of this will be done through “Bindings” which are the different API packages for various devices much like “Components” in Home Assistant. Now this is where openHAB falls behind Home Assistant as openHAB does not have nearly the same size library of “Bindings” as Home Assistant does “Components” but for my application, everything I have is supported so its a non-issue. To start adding things you basically select the appropriate “Binding” from the Add-ons section and then from the “Inbox” scan for devices, it really could not be simpler. In most cases, no coding (like yaml) is needed to add devices and you can quickly have your devices added.

Now there is one more aspect that I feel makes openHAB vastly superior to Home Assistant and that is in its documentation. Everything you could need can be found at https://www.openhab.org/docs/tutorial/. I know what you are going to say Home Assistant has this as well but I find that most of the time the documentation for Home Assistant makes assumptions that people are as technically savvy as the writers and that is not always the case. I usually find myself searching all over the place piecing bits of information together to get things set up in Home Assistant. With the documentation available for openHAB, however, this is not the case, everything I needed was right there and coupled with the GUI things were straight-forward and easy to set up and this alone could be what gets me to continue using openHAB.

Now, am I going to abandon SmartThings for openHAB probably not but I will be using openHAB to supplement my SmartThings system and hopefully accomplish some pretty cool things. Between openHAB, its clean UI and available integrations, SmartThings, IFTTT and MQTT the automation opportunities ahead of me are endless and exciting and I can not wait to do more.

Are any of you running openHAB? Let me know your experiences in the comments below.

Advertisements

Mike View All

I am passionate about the IoT and connected devices. Using connectivity to automate our lives will empower civilization to achieve greatness.

2 thoughts on “Turn your Raspberry Pi into a Smart Home Hub with openHAB Leave a comment

  1. “A home automation enthusiast doesn’t have to be a Linux enthusiast!” was the line that made me looked into it.
    If you are not well informed, specialized or know enough about Raspian, Linux, shell commands and so on, better forget Openhabian.
    I had downloaded the image file of Openhabian because it would be a Hassle-free openHAB Setup!
    Maybe I had a bad SD card because it looked like a lot of hassle to make this work after a month of working with it but even a new one did not help made this a Hassle-free setup.
    Make MQTT working stable after installing the binding because you need to add a line into a cfg file!. Which persistence binding do you need to install to make a simple graph or let the state of a simple button restore after a restart? Items files made by hand or Item linking set to simple mode? Is my ESP8266-01 a thing or do I need to write a item file for it? Why can Paper-ui show a perfect map (regional settings) but do I need to create a separate coordinates file to use this in habpanel?
    Many so could links are pointing to old pages or pages not found, mainly (I guess) because there are different versions out there.

    Even Openhab “makes assumptions that people are as technically savvy as the writers and that is not always the case”
    So it’s better to know a lot about the Rasberry Pi, Linux, shell commands system and don’t relay on “a Hassle-free openHAB Setup!”
    Maybe I have to do it like you did.

    Like

    • It really all depends on what you are trying to do. Basic setup and addition of connected and web api devices is pretty straight forward with very little reading to accomplish. More advanced things like MQTT will always require more knowledge as that is just the nature of such things. I for one however and happy to not have to deal with yaml and find the graphical UI for openHAB to be much easier to use than the text based set up of Hass but again it all depends on what you are trying to do. In my testing I only found on “make your own hub” solution that was easier to use than openHAB and that will be the topic of a future article.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: