Install OpenHAB on Raspberry Pi

Install latest version of openHAB on Raspberry Pi and get the demo running. For many makers, the internet of things is all about home automation. openHAB is the leading open-source home automation hub.

I struggled with openHAB's installation instructions. Home Automation for Geeks' instructions helped me get an old version running (1.7). However, I wanted to install the latest stable version.

The instructions were verified with 1.8.3, but should work for any new stable version.

In general, raspbian and debian variants use packages enabling simple installation with apt-get. However, java is operating system independent and uses zip files for installation. openHAB has apt-get install, but it didn't work for me.


  • Replace text enclosed in spades with an actual value ♣replace-this♣
  • Remove spaces around the colon (https : //)
  • Setup Raspberry Pi (any model) running raspbian or DietPi
  • I use a MacBook but any computer can be used. I think the only change if you are using a PC, is to use putty to login and open a terminal window.
  • My openHab Raspberry Pi is using ♣ip-address♣ =

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Step-by-Step Install

Step-by-step instructions follow, or go to the next step and use an unattended install to do the steps below.

Open terminal window and ssh into Raspberry Pi

$ ssh pi@♣ip-address♣

Always update and upgrade

$ cd ~/.
$ sudo apt-get update
$ sudo apt-get upgrade

Install java and eclipse

Check if java and eclipse are installed. If installed, then you should see /usr/bin/java or /usr/bin/eclipse. If not installed, install them

$ which java
$ sudo apt-get install oracle-java8-jdk -y 
$ which eclipse
$ sudo apt-get install eclipse -y

Install Mosquito

Remove the spaces around the colons.

$ wget http : // 
$ sudo apt-key add mosquitto-repo.gpg.key
$ rm mosquitto-repo.gpg.key
$ cd /etc/apt/sources.list.d/
$ sudo wget http : //
$ sudo apt-get update
$ sudo apt-get install mosquitto mosquitto-clients

Test Mosquito

$ mosquitto_sub -d -t hello/world

Open a second terminal and ssh in

$ ssh pi@♣ip-address♣
$ mosquitto_pub -d -t hello/world -m "Hello from terminal window 2!"

The message from window 2 should appear in the first window.

Logout and close second terminal window.

CTRL-c in the first terminal window

Make directories

$ ssh pi@♣ip-address♣
$ sudo mkdir /opt
$ sudo mkdir /opt/openhab
$ sudo chmod -R ugo+rw /opt/openhab

Get links to latest version of openHAB

On MacBook (or PC):

  • open browser
  • open text file

In browser, go to openHAB downloads page and copy the following links to text file:

  • Runtime core
  • Addons
  • Demo setup

To copy a link on a MacBook, hold CTRL and click on link, then select Copy Link

Paste each link into text file. You will see something like this:


CTRL-Click on Download and Edit Link. Select the link, copy it and paste it to text file. You will see something like this:

https : //

Remember to remove spaces around the colon.

As of 27MAY2016, the current openHab links for the stable release 1.8.3 are:

♣runtime-core♣ = ♣https : //♣

♣addons♣ = ♣https : //♣

♣demo-setup♣ = ♣https : //♣

Download latest version of openHAB

Run the following commands using links and names from above

$ cd /opt/openhab
$ sudo wget ♣runtime-core♣
$ ls
$ sudo unzip ♣runtime-core-zip-file♣
$ sudo rm ♣runtime-core-zip-file♣

$ cd /opt/openhab/addons
$ sudo wget ♣addons♣
$ ls
$ sudo unzip ♣addons-zip-file♣
$ sudo rm ♣addons-zip-file♣

$ cd ..
$ sudo wget ♣demo-setup♣
$ ls
$ sudo unzip ♣demo-setup-zip-file♣
$ sudo rm ♣demo-setup-zip-file♣
$ sudo chmod +x

Start openHAB running

$ cd /opt/openhab
$ sudo ./

openHAB takes about 5 minutes to start

In the browser, open a new tab and go to (remove spaces around colon):

http : //♣ip-address♣:8080/

And it should work!

However, openHAB should really start and run on boot.

Stop openHAB

CTRL-z to stop openHAB. I haven't figured out how to recover from stopping openHAB. The only way to get openHAB to work after stopping is to reboot.

Add username and password

$ sudo nano /opt/openhab/configurations/users.cfg 

and add the following line, replacing names in spades with real values. Even though I am using diet-pi, I created a pi username.


Add MQTT binding

$ cd /opt/openhab/configurations
$ sudo cp openhab_default.cfg openhab.cfg
$ sudo nano openhab.cfg

CTRL-w to search for mqtt and uncomment the lines and edit to look like:


Use localhost and not your ♣ip-address♣. DHCP might change the ip-address and localhost will keep up with these changes.

CTRL-o, ENTER, CTRL-x to write and exit nano editor

Start openHAB on boot

Unless running an old version of raspbian, don't use init.d. Diet-Pi and raspbian use systemd, which is is a linux init system to bootstrap user space and manage processes. To check if systemd is being used, enter the command:

$ ps -p 1 -o comm=

Make system directory if it doesn't exist and create a start-up file

$ sudo mkdir /usr/lib/systemd/system 
$ sudo nano /usr/lib/systemd/system/openhab.service

And add

Description=openHAB Home Automation Bus

ExecStop=kill -SIGINT $MAINPID


To save and exit: CTRL-o, ENTER, CTRL-x

Change owner recursively on openhab.

$ sudo chown -R pi:pi /opt/openhab

Reload systemd to make the daemon aware of the new configuration.

$ sudo systemctl --system daemon-reload
$ cd /usr/lib/systemd/system
$ sudo systemctl enable openhab.service
$ sudo systemctl start openhab.service 
$ sudo reboot

Fix any issues in the logs. To see the log, enter the command:

$ sudo journalctl -f -u openhab.service

CTRL-c to stop

$ sudo reboot

openHAB takes about 5 minutes to start

In the browser, open a new tab and go to

http : //♣ip-address♣:8080/

And it works!

Step 2: Unattended Install of OpenHAB Demo

Make openHAB Demo Installation very easy by automating the previous step using a bash unattended install script. The script assumes a raspberry pi running raspbian or dietpi, which was setup using one of the embedded links.

I finished the script on github and

  • tested the source on dietpi
  • tested unattended install script on dietpi
    • ran one time
    • ran multiple times, with CTRL-c interrupts
  • tested unattended install script on raspbian

The script assumes the username = pi, and the password = raspberry, and the script is trying to install openHAB 1.8.3. If these aren't correct, then edit the file accordingly.

Open terminal window on a MacBook or PC and run the following commands:

$ ssh pi@♣ip-address♣
$ sudo wget ""
$ sudo chmod o+x
$ sudo bash
$ sudo reboot

The script takes about ten minutes to run onraspbian.

Be sure to reboot the Raspberry Pi and wait 5 minutes until openhab starts

And it should work!

Once it works, be sure to change the hostname and password.

Internet of Things Contest 2016

Participated in the
Internet of Things Contest 2016

1 Person Made This Project!


  • Assistive Tech Contest

    Assistive Tech Contest
  • Reuse Contest

    Reuse Contest
  • Made with Math Contest

    Made with Math Contest

48 Discussions


Question 1 year ago on Introduction

Hi. Thanks for the instructable, I really appreciate you taking the time to write it. This is the first project for my RPi 2b which has been sitting around patiently for two years waiting for me to get inspired; the posibility of a 'free' home automation hub is what encouraged me to try this out.

Unfortunately I'm having quite a lot of problems just getting OH installed. Most of the errors I'm getting seem to be permission related. I'm going to try a 'from-scratch' approach and flash NOOBS again to see if it helps but is there something else I can try if that doesn't work?

I've tried running as root instead of pi but still the same. I can create directories but then can't write to them. I can't even get past the first line on your instructable because when I ssh I get 'connection refused' lol



2 years ago

Got it. Used unattended install and it worked great. Thanks.


2 years ago

Dont misunderstand, I think you did a great instructable, but after a few days experience with openhab, I get more and more frustrated by the application. Apart from what I mentioned earlier there is just another problem with it every time I try it. Not anything that I would trust my house to. Dont want to come from holiday home and find the heating up to 30 degrees, all the lights on and my alarm not functioning.
I sure hope your experience with it is better

2 replies

Reply 2 years ago

I am a bit insane. Before I start on an instructable, I make a list of my requirements and then do a search for all possible solutions. Some solutions I throw out before I get too deep because they don't meet my requirements. Of those solutions remaining, I try to implement each one to some level. I'll start a draft instructable for each solution, and then at some point give up on it because it is more problematic than helpful. I then move on to the next one.

I am sorry that OpenHab is not working for you.

I found that OpenHab was confusing to install and get running, which is why I wrote the instructable. However, OpenHab meets my requirements and seems to be the most extensible home automation solution and works with my other home automation stuff: garage door opener, security system, Ring, Nest, OpenSprinkler, Echo, etc. I haven't done lights yet.

Yes, I agree there are issues. At about 2am one night, my garage door opened and then the security alarm went off when the door between the house and garage was apparently opened. However, I am still not sure what happened. Because my dog and I were up pretty quick and outside, but there was no one around. Did someone actually try to break in, or did something just go wrong in the code? I've put in some safeguards to prevent cached commands from being executed at unexpected times, and some more messages to log events if it happens again.

There are many other DIY solutions. And, if you want to try off-the-shelf, I lean towards Samsung's SmartThings Home Automation Hub.


Reply 2 years ago

Jeff, thanks for your extensive reply. I want to be absolutely clear your install guide is the best I came across. That I have problems with openhab is absolutely not on your account.
I havent given up yet, so I may just wipe my entire TPi clean, do a fresh Raspi install and a fresh Openhab install and apart from Webmin put nothing else on it.

The people behind Openhab apparently agree that it has issues as one of the flash words for OH2 is 'less complicated to install' and 'less issues in running' (or similar words)
Not much of an 'off the shelf man' but if you have any other DIY suggestion, always interested to have a look.
Thanks again and enjoy yr day


2 years ago

Great instructable. Tnx
yet I am till now not really trilled by the combo Raspberry and Openhab.
not sure which one of the two is unreliable.

After setting it up and getting it to work.
it needed frequent restarts,sometimes just the openhab sometimes both.
and then it stopped working giving me all sorts of errors on non queriable persistence modules (e.g. rr4dj) missing Mongo databases and what have you.

I am sure there is all a reason for it but I am a simple man. If at one moment it works and then stops and can't get it to work again then obviously it isnt very stable.
I am going to try a fresh install of Raspi and openhab and see where that brings me


3 years ago

my service not started... got some error msg, how do i solve this?

sudo journalctl -f -u openhab.service

-- Logs begin at Fri 2016-11-04 12:59:30 CET. --

Nov 04 12:59:36 HOMESRV systemd[1]: Starting openHAB Home Automation Bus...

Nov 04 12:59:36 HOMESRV systemd[1]: Started openHAB Home Automation Bus.

Nov 04 12:59:36 HOMESRV systemd[1]: openhab.service: main process exited, code=exited, status=200/CHDIR

Nov 04 12:59:36 HOMESRV systemd[1]: Unit openhab.service entered failed state.

Nov 04 12:59:36 HOMESRV systemd[1]: openhab.service holdoff time over, scheduling restart.

Nov 04 12:59:36 HOMESRV systemd[1]: Stopping openHAB Home Automation Bus...

Nov 04 12:59:36 HOMESRV systemd[1]: Starting openHAB Home Automation Bus...

Nov 04 12:59:36 HOMESRV systemd[1]: openhab.service start request repeated too quickly, refusing to start.

Nov 04 12:59:36 HOMESRV systemd[1]: Failed to start openHAB Home Automation Bus.

Nov 04 12:59:36 HOMESRV systemd[1]: Unit openhab.service entered failed state.

4 replies

Reply 3 years ago

Also trying to change the start.h following this instructions:

it doesnt help.

service openhab status

● openhab.service - openHAB Home Automation Bus

Loaded: loaded (/usr/lib/systemd/system/openhab.service; enabled)

Active: failed (Result: start-limit) since Fri 2016-11-04 14:15:00 CET; 3min 53s ago


Process: 577 ExecStart=/opt/openhab/ (code=exited, status=200/CHDIR)

Main PID: 577 (code=exited, status=200/CHDIR)


Reply 3 years ago

From your posts, it looks like you are trying things from other sites to get openhab to work. If you are trying my instructable and it does not work, I can help.

I believe the unattended install script will fix many problems, but I have not tried it on other people's instructions. Have you tried logging into your raspberry pi and running these commands:

$ ssh pi@♣ip-address♣

$ sudo wget ""

$ sudo chmod o+x

$ sudo bash

$ sudo reboot

Wait about five for the raspberry pi to boot and openhab to start. Open a browser on your laptop and enter:


Be sure to replace ♣ip-address♣ with the actual raspberry pi's ip address.

Can you run the following commands and post results?

$ cat /etc/*-release

$ uname -mrs

$ ps -A | egrep -i "gnome|kde|mate|cinnamon|lxde|xfce|jwm"

Also, could you try the following command and post 100 or so lines to pastebin?

$ sudo journalctl -f

Finally, can you run this command and post the results:

$ /usr/lib/systemd/system/openhab.service


Reply 3 years ago

Thanks for ur reply.

i followed your intructions, install the latest build of Jessie, turn on VNC and after that starting ur how to.

everything was ok except the last step installing as service

this is the last execute in terminal:

pi@HOMESRV:~ $ sudo systemctl start vncserver-x11-serviced.service
pi@HOMESRV:~ $ sudo chown -R pi:pi /opt/opanhab/
pi@HOMESRV:~ $ sudo systemctl --system daemon-reload
pi@HOMESRV:~ $ sudo systemctl enable openhab.service
pi@HOMESRV:~ $ sudo systemctl start openhab.service
Job for openhab.service failed. See 'systemctl status openhab.service' and 'journalctl -xn' for details.
pi@HOMESRV:~ $

currently i dont have time for reinstalling the whole openhab, because already using and configuring, testing some MQTT device on it.

Next time i will try the install.

Here it is the other logs:

pi@HOMESRV:~ $ cat /etc/*-release
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION="8 (jessie)"
pi@HOMESRV:~ $ uname -mrs
Linux 4.4.26-v7+ armv7l
pi@HOMESRV:~ $ ps -A | egrep -i "gnome|kde|mate|cinnamon|lxde|xfce|jwm"
22 ? 00:00:00 kdevtmpfs
pi@HOMESRV:~ $ sudo journalctl -f
-- Logs begin at Tue 2016-11-08 00:34:16 CET. --
Nov 08 00:39:19 HOMESRV systemd[1]: Stopping openHAB Home Automation Bus...
Nov 08 00:39:19 HOMESRV systemd[1]: Starting openHAB Home Automation Bus...
Nov 08 00:39:19 HOMESRV systemd[1]: openhab.service start request repeated too quickly, refusing to start.
Nov 08 00:39:19 HOMESRV systemd[1]: Failed to start openHAB Home Automation Bus.
Nov 08 00:39:19 HOMESRV systemd[1]: Unit openhab.service entered failed state.
Nov 08 00:43:03 HOMESRV sudo[1174]: pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/bin/journalctl -f -u openhab.service
Nov 08 00:43:03 HOMESRV sudo[1174]: pam_unix(sudo:session): session opened for user root by pi(uid=0)
Nov 08 00:43:34 HOMESRV sudo[1174]: pam_unix(sudo:session): session closed for user root
Nov 08 00:44:53 HOMESRV sudo[1188]: pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/bin/journalctl -f
Nov 08 00:44:53 HOMESRV sudo[1188]: pam_unix(sudo:session): session opened for user root by pi(uid=0)
pi@HOMESRV:~ $ /usr/lib/systemd/system/openhab.service
-bash: /usr/lib/systemd/system/openhab.service: Permission denied

Reply 3 years ago

There is typo in this line (it should be openhab):

sudo chown -R pi:pi /opt/opanhab/

Explains the permission denied, and the issue in the first part. Running the UAI script would avoid things like this.


3 years ago

Thanks a million!

I have been struggling to get it to install and run for the past few days...

I am looking to connect an enocean module to my pi and everything integrated with openhab.

This is a great starting point for me.

Thanks again!


3 years ago

Odd problem I don't know how to troubleshoot.

Before installing openhab using this instructable, my pi3 connected to my ethernet just fine. After installing but before adding openhab to the boot, all was still good (and openhab worked too!). Added the openhab.service segment and it stopped connecting. removed the openhab.service and now it only connects on every other reboot.

Boot message it is hanging on is: (works every other time)

A start job is running of LSB: Rais network interfaces.

How do I troubleshoot this one??

2 replies

Reply 3 years ago

I am not sure I understand the issue. Is the Raspberry Pi hanging, or is your laptop unable to connect using a browser to OpenHab on the RPI? Please provide additional details.

This seems to be an incomplete statement: "Boot message it is hanging on is:" What is the message it is hanging on? A boot message seems like the raspberry pi is hanging.

Also, this doesn't look correct: "LSB: Rais network interfaces"

Are you using Wi-Fi or wired connection? If Wi-Fi on Pi3, how is it configured?

Are you using DietPi or Raspbian?

Did you try running the unattended install, it should fix whatever is wrong?

My wild guess is the openhab directory does not have the correct permissions. Some file in one of the sub-directories contains a file that cannot be read or written.

A couple more guesses:

* If all of the addons are installed, then it takes 5+ minutes for openhab to get to a stable state. Are you waiting long enough?

* If the raspberry pi is operating correctly, then it should work the same way on every boot. Can you measure voltage on the raspberry pi 5v and ground pins? If voltage fluctuates and drops below 4.9v, then the power supply is at issue.

santhosh B

3 years ago

Hi, I am new to MQTT and openHAB. By following your instructions successfully installed MQTT and openHAB on Raspberry pi 3. Thank you for the instructions.

I would like to know how to send MQTT subscribed messages to openHAB. For example client running on rpi3 has subscribed to topic /home/light1. I would like to send this to openHAB and see the status in web browser. Please guide me.

1 reply

3 years ago

Hi, great directions. Question though, once you get the service setup for the auto reboot start how do you stop just the openhab service? then how would you restart in debug mode? i need to check out the logs in debug mode.


1 reply

To stop after auto reboot, try:

$ sudo systemctl stop openhab.service

I have not used debug. However, I use this command to view logs:

$ sudo journalctl -f -u openhab.service


3 years ago

But I must add, I have been playing around with OpenHAB a lot on Windows before installing it on my Pi.