Introduction: OpenHAB on Raspberry Pi

Picture of OpenHAB on Raspberry Pi

NOTE: Updated 6/4/16 This instructable is outdated. It can certainly be of assistance but please also checkout Jeff's instructable below. Two little babies can suck the free time right out of you.
https://www.instructables.com/id/Install-OpenHAB-on-Raspberry-Pi/

This instrucable covers how to download and install openHAB on your Raspberry Pi through the command line. I also go one step further and show you how to configure your openHAB to load at boot.

As many of you may know openHAB is a server system design to integrate the myriad of available home automation gadgets in the market and control them with one single interface. You can do away with all of the apps that come with each individual gadget and have one central control.

I understand that many people haven't taken the plunge to use openHAB simply because they think it is too complex. I put this instructable together so others can see that there is really nothing to it. I myself had a few issue when I was installing openHAB so I thought others might find this helpful.

Step 1: Downloading and Installing OpenHAB on Pi

Picture of Downloading and Installing OpenHAB on Pi

Its always good practice to be certain you are working with the latest updated software packages so lets begin with this:

sudo apt-get updatesudo apt-get upgrade

Certain apps may require you to update the firmware but typically its not a requirement. I suggest to do it anyway.

sudo rpi-update

You can use any kind of way that you would like to copy files to your Pi. I choose to do download them. I also like to download them directly to the folder that I will be extracting them from. I then do some housekeeping and remove the unnecessary zip file. First lets make the folders we need.

sudo mkdir /opt/openhab


You will then want to download the latest release to that folder. You can do that by going to the openHab downloads page and right clicking on the runtime core download and copying the link address to get the latest version. You can then replace the url below with the one you copied.

cd /opt/openhab

wget https://github.com/openhab/openhab/releases/download/v1.5.1/distribution-1.5.1-runtime.zip


Ok, lets install this b*tch. The zip files that you downloaded should be extracted to the correct location already. If your not already there go to the openhab folder and extract the runtime zip file there.

cd /opt/openhabsudo

unzip distribution-1.5.1-runtime.zip


Lets now remove the zip file which will no longer be needed.

rm distribution-1.5.1-runtime.zip


Great, the runtime is installed and the zip files erased, but in order for openHAB to work you will need to add bindings. Upon extrating the runtime zip a "addons" folder was created. All bindings belong in this folder. Go to the addons folder and extract the addons zip. First lets download them to the appropriate folder.

cd addons/

wget https://github.com/openhab/openhab/releases/download/v1.5.1/distribution-1.5.1-addons.zip


This contains all the bindings available for openHAB. As stated in the openHAB wiki, Bindings are optional packages that can be used to extend functionality of openHAB. By help of bindings openHAB users can e.g. access Asterisk communications software or connect to the KNX Home Automation Bus.

Lets just install all of them and later we can sift through and decide which one we keep. You simply remove the .jar file from the addons folder.
sudo unzip distribution-1.5.1-addons.zip
Remove or erase the zip file.
rm distribution-1.5.1-addons.zip

Next lets go back one folder to the openhab folder and make a copy of the "openhab_default.cfg" file. You will call the copy "openhab.cfg". In the event that you have to update your openhab the default file will be updated as well. By making a copy of this file, openhab will use this file for configurations and also not update it. Since you will be making your own custom configurations, it is important that those get written in the "openhab.cfg" file for safe keeping.

cd ..
sudo cp configurations/openhab_default.cfg configurations/openhab.cfg


In order to understand how this crazy thing works I recommend deploying the demo app. Its a good way to get your foot on the ground and make some sense of this.

cd /opt/openhab

wget https://github.com/openhab/openhab/releases/download/v1.5.1/distribution-1.5.1-demo-configuration.zip


Go to the openhab folder and extract the demo zip files there.
cd /opt/openhab

sudo unzip distribution-1.5.1-demo-configuration.zip


remove the garbage files

rm distribution-1.5.1-demo-configuration.zip 

By default the "start.sh" script is not an executable file. Do the following in order to make it executable:

sudo chmod +x start.sh

sudo ./start.sh



And the fun begins! You should have a fully loaded demo that you can use to familiarize yourself with openHAB. Just go to your telephone or computer and place the following url in your favorite browser. Be sure to replace the ip address with the Ip address of your Pi.

http://192.168.X.XXX:8080/openhab.app?sitemap=demo

Step 2: Configuring OpenHAB to Start Automatically at Boot

In the event of a power surge, outage or if you decide to restart your Pi, your OpenHAB program will need to be re-booted. That is a big pain the rear end so we will want to configure it to boot at start.

First off you will want to create a new file in the /etc/init.d folder called "openhab".

You will want to add a few lines of code to your openhab file by using the nano editor or your favorite editor of choice.
sudo nano /etc/init.d/openhab

Add this code:
#! /bin/sh<br>### BEGIN INIT INFO # Provides: openhab # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: OpenHAB Daemon ### END INIT INFO# Author: Thomas Brettinger# Do NOT "set -e"# PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/binDESC="Open Home Automation Bus Daemon" NAME=openhab DAEMON=/usr/bin/java PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME ECLIPSEHOME="/opt/openhab"; HTTPPORT=8080 HTTPSPORT=8443 TELNETPORT=5555 # be sure you are adopting the user to your local OH user RUN_AS=pi# get path to equinox jar inside $eclipsehome folder cp=$(find $ECLIPSEHOME/server -name "org.eclipse.equinox.launcher_*.jar" | sort | tail -1);DAEMON_ARGS="-Dosgi.clean=true -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Djetty.port=$HTTPPORT -Djetty.port.ssl=$HTTPSPORT -Djetty.home=$ECLIPSEHOME -Dlogback.configurationFile=$ECLIPSEHOME/configurations/logback.xml -Dfelix.fileinstall.dir=$ECLIPSEHOME/addons -Djava.library.path=$ECLIPSEHOME/lib -Djava.security.auth.login.config=$ECLIPSEHOME/etc/login.conf -Dorg.quartz.properties=$ECLIPSEHOME/etc/quartz.properties -Djava.awt.headless=true -jar $cp -console ${TELNETPORT}"# Exit if the package is not installed [ -x "$DAEMON" ] || exit 0# Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME# Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh# Define LSB log_* functions. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present # and status_of_proc is working. . /lib/lsb/init-functions# # Function that starts the daemon/service # do_start() { # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE --chuid $RUN_AS --chdir $ECLIPSEHOME --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --chuid $RUN_AS --chdir $ECLIPSEHOME --exec $DAEMON -- $DAEMON_ARGS \ || return 2 # Add code here, if necessary, that waits for the process to be ready # to handle requests from services started subsequently which depend # on this one. As a last resort, sleep for some time. return 0 }# # Function that stops the daemon/service # do_stop() { # Return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 # Wait for children to finish too if this is a daemon that forks # and if the daemon is only ever run from this initscript. # If the above conditions are not satisfied then add some other code # that waits for the process to drop all resources that could be # needed by services started subsequently. A last resort is to # sleep for some time. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON [ "$?" = 2 ] && return 2 # Many daemons don't delete their pidfiles when they exit. rm -f $PIDFILE return "$RETVAL" }# # Function that sends a SIGHUP to the daemon/service # do_reload() { # # If the daemon can reload its configuration without # restarting (for example, when it is sent a SIGHUP), # then implement that here. # do_stop sleep 1 do_start return 0 }case "$1" in start) log_daemon_msg "Starting $DESC" do_start case "$?" in 0|1) log_end_msg 0 ;; 2) log_end_msg 1 ;; esac ;; stop) log_daemon_msg "Stopping $DESC" do_stop case "$?" in 0|1) log_end_msg 0 ;; 2) log_end_msg 1 ;; esac ;; status) status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? ;; #reload|force-reload) # # If do_reload() is not implemented then leave this commented out # and leave 'force-reload' as an alias for 'restart'. # #log_daemon_msg "Reloading $DESC" "$NAME" #do_reload #log_end_msg $? #;; restart|force-reload) # # If the "reload" option is implemented then remove the # 'force-reload' alias # log_daemon_msg "Restarting $DESC" do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop log_end_msg 1 ;; esac ;; *) #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 exit 3 ;; esac :

You can also go here to see the readable version or you can copy and paste the code from there.

You may need to change the RUN_AS=pi to your current user.

Lastly you will want to make this an executable file.
sudo chmod a+x /etc/init.d/openhab

And for it to automatically boot at the start of Pi
sudo update-rc.d openhab defaults


If you get an error that looks like this:
insserv: Script openhab is broken: incomplete LSB comment. insserv: missing `Provides:' entry: please add. insserv: missing `Required-Start:' entry: please add even if empty. insserv: missing `Required-Stop:' entry: please add even if empty. insserv: missing `Default-Start:' entry: please add even if empty. insserv: missing `Default-Stop:' entry: please add even if empty. insserv: Default-Start undefined, assuming empty start runlevel(s) for script `openhab' insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `openhab'


Then you have an indentation problem. Sometimes upon pasting into your editor the text gets placed into an easy to read format which places indentations into some of the initial lines of code. Any information that is written for update-rc.d must be in first column. And there should not be any tabulation or space before the "#". If there are any remove them or you will generate that error.

Go back to your file and double check.
sudo nano /etc/init.d/openhab


The first few columns should look like this (DO NOT COPY AND PASTE, CONTAINS ASCII CHARACTER SPACING) just use it as a visual example:

#! /bin/sh
### BEGIN INIT INFO

# Provides: openhab
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: OpenHAB Daemon
### END INIT INFO


Notice how there are no spaces or indents before each # sign.

Complete, your Raspberry Pi will now boot openHAB at start.

Step 3: Extras (Admin Console)

FYI
There is a cool Admin Console for openHAB called HABmin. Its great for performing administrative tasks as well as configuring various procedures. Google it and decide whether or not its right for you. Its quite easy to install. If you are interested I have created an instructable on how to install it here.

http://instructables.com/id/openHAB-Admin-Console-...

Comments

jeff.cartwright.562 made it! (author)2016-06-04

I was unable to get openHAB instructions to work. Your tutorial helped greatly. I made some changes and documented them here: https://www.instructables.com/id/Install-OpenHAB-o...

Hi all!

I am likewise unable to get the startup script to work. I follow all the instructions very carefully. I do not see any errors but I do not get a service to start (I cannot telnet to localhost:8080). I see NOTHING in /var/log/openhab.log. I chown'd and chgrp/d everything to pi:pi, opened up the log file to 777. Any ideas on how to troubleshoot next?

Thanks!

The script needs access to the openhab directories. Run:
sudo chmod -R ugo+rw /opt/openhab

then
sudo . /start. sh

If you reboot raspberry pi, then start. sh stops and you will want it to start on boot. If you create service, then this comnand shows status

$ sudo journalctl -f -u openhab.service

On your laptop, open a browser and in the url field enter [remove spaces around colon and usr raspberry pi address ]

http : //♣ip-address♣:8080/openhab.app?sitemap=demo

Ah ok, thanks. That makes sense. I'll clean up my scripts and open up the directories as you mentioned. Thanks!

DanJ53 (author)DanJ532016-07-06

Actually I was just able to get this to work by following uvajed_again's advice by setting the runas user to root. It is still unclear to my why this works and why setting it to pi:pi does not, especially since I couldn't find any logs anywhere explaining anything.

Thanks Jeff. I added a link to you ible on mine.

uvajed_again (author)2016-05-27

I had varying success getting openhab to fully work using different sites. Each site had something different and something wrong. Since your tutorial was that last I could find, I decided to diagnose and fix the problem here. The auto start script was not starting openhab. It turns out that during boot, the user is root, not pi. So to fix this, in the auto start script, I changed RUN_AS=pi to RUN_AS=root. That fixed the start problem, but then you must use sudo when using the script at runtime:

sudo /etc/init.d/openhab status
sudo /etc/init.d/openhab stop
sudo /etc/init.d/openhab start

BTW, I installed openhab v1.8.3 using:
sudo mkdir /opt/openhab
cd /opt/openhab
sudo wget https://bintray.com/artifact/download/openhab/bin/distribution-1.8.3-runtime.zip
sudo unzip distribution-1.8.3-runtime.zip
sudo rm distribution-1.8.3-runtime.zip

cd /opt/openhab
sudo mkdir addons_repo
cd addons_repo
sudo wget https://bintray.com/artifact/download/openhab/bin/distribution-1.8.3-addons.zip
sudo unzip distribution-1.8.3-addons.zip
sudo rm distribution-1.8.3-addons.zip

cd /opt/openhab
sudo https://bintray.com/artifact/download/openhab/bin/distribution-1.8.3-demo.zip
sudo distribution-1.8.3-demo-configuration.zip
sudo rm distribution-1.8.3-demo-configuration.zip

shedzong (author)2015-11-20

tdubliture,

I got a response of "update-rc.d: using dependency based boot sequencing" and that is fine.

The fact that it says that it can't see your directory tells me there's still a permissions problem. Is it set up to run as user pi? If so this should fix that:
sudo chown -hR pi:pi /opt/openhab

or if running as say, bananapi then this:
sudo chown -hR bananapi:pi /opt/openhab

And of course you already did this I guess: sudo chmod a+x /etc/init.d/openhab

shedzong (author)2015-01-21

The answer was that the openHAB files had owner of root. Doing a chown to make them pi pi made it come to life.

JamesK10 (author)shedzong2015-02-04

Can you elaborate on the steps you performed to allow it to auto-start? I am using pi as the user also. Not a heavy user in linux, I know enough to get me headaches. Thanks in advance.

Arizno (author)JamesK102015-02-05

Did you reboot your Pi and allow ample time for openhab to boot up? Did you also follow the others recommendation of "chown"? Lastly are you able to start and stop openhab manualy by " /etc/init.d/openhab start" or "/etc/init.d/openhab stop"?

tdubliture (author)Arizno2015-11-19

I am having the same problem "using dependency based boot sequence" I did all of the other recommendation of chown. i am unable to start and stop openhab manually. it tells me that no such directory exists. yet if i drill down to the path i see openhab. if when i am in the init.d dir and type in openhab it says command not found. sorry to be a noob. not sure where to go from here

JamesK10 (author)Arizno2015-02-05

Thought I actualIy performed a chown. A little research on how to verify (ls -l /opt/openhab) and now it works like a charm! Know of any good light reading on using Arduino Micros as senders to this Rpi receiver would be appreciated and thanks for the kickstart!

sas0031 (author)shedzong2015-02-15

What command did you use to change the ownership, and did you do any additional commands? I used:

sudo chown pi /etc/init.d/openhab

sudo update-rc.d openhab defaults

and still received the message "update-rc.d: using dependency based boot sequencing" and still can't get it to run at startup.

Thanks!

shedzong (author)sas00312015-02-15

Use this on your configuration files to make your owner & group pi: : sudo chown -hR pi:pi /opt/openhab

That is the correct message from your update command.

Use the startup script from here: https://github.com/openhab/openhab/wiki/Samples-Tricks#how-to-configure-openhab-to-start-automatically-on-linux

You need to remove the 3 spaces from the start of each line for it to work properly.

Arizno (author)shedzong2015-02-16

Thank you shedzong! I just added the github link to the instructable in case it is helpfull others.

MortenCopenhagen (author)2015-04-12

I was not able to make this work. I suspect that it could be related to me not really being able to edit and transfer text files correctly. Instead I just used pico to edited the file

/etc/rc.local

and added this line towards the end:

sudo /opt/openhab/start.sh

And it works perfectly. Also I did remember to remove the openhab file and do a remove with update-rc.d

Would you care to let me know the pros and cons for doing the autostart this much simpler way?

Cheers and Thanks from Copenhagen

START ON BOOT WORKS

I also had an issue and I spent hours trying to fix the script with no success. Finally I found the site below, when copying that script provided in the article, it worked. I would explain the differences but the scripts are very different but I can confirm it worked for me. I am running a Raspberry Pi 2 with NOOB.

http://www.homeautomationforgeeks.com/openhab_star...

In an effort to ensure this is not lost if the link dies, here is the script:

#!/bin/sh
### BEGIN INIT INFO
# Provides: openhab
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: OpenHAB Daemon
# Description: Build your smart home in no time!
### END INIT INFO
ROOT_DIR=/opt/openhab
# set path to eclipse folder. If local folder, use '.'; otherwise, use /path/to/eclipse/
eclipsehome="$ROOT_DIR/server";
# set ports for HTTP(S) server
HTTP_PORT=8080
HTTPS_PORT=8443
# get path to equinox jar inside $eclipsehome folder
cp=$(find $eclipsehome -name "org.eclipse.equinox.launcher_*.jar" | sort | tail -1);
# This next line determines what user the script runs as.
# Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
#USER=root
DAEMON_USER=root
DAEMON_NAME=openhab
DAEMON=/usr/bin/java
DAEMON_ARGS="-Djna.boot.library.path=/usr/lib/jni -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0 -Dosgi.clean=true -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Djetty.port=$HTTP_PORT -Djetty.port.ssl=$HTTPS_PORT -Djetty.home=. -Dlogback.configurationFile=configurations/logback.xml -Dfelix.fileinstall.dir=addons -Djava.library.path=lib -Djava.security.auth.login.config=./etc/login.conf -Dorg.quartz.properties=./etc/quartz.properties -Dequinox.ds.block_timeout=240000 -Dequinox.scr.waitTimeOnBlock=60000 -Dfelix.fileinstall.active.level=4 -Djava.awt.headless=true -jar $cp $* -console "
PIDFILE=/var/run/$DAEMON_NAME.pid
. /lib/lsb/init-functions

do_start() {
log_daemon_msg "Starting system $DAEMON_NAME daemon"
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --chdir $ROOT_DIR --exec $DAEMON -- $DAEMON_ARGS
log_end_msg $?
}
do_stop() {
log_daemon_msg "Stopping system $DAEMON_NAME daemon"
start-stop-daemon --stop --pidfile $PIDFILE --retry 10
log_end_msg $?
}

case "$1" in

start|stop)
do_${1}
;;

restart|reload|force-reload)
do_stop
do_start
;;

status)
status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}"
exit 1
;;

esac
exit 0

JesperG (author)MortenCopenhagen2015-07-25

Just for other noobs like me trying to do this: The remove command is:

sudo update-rc.d openhab remove

sudo rm /etc/init.d/openhab

And remember to put an "&" at the command end (before exit 0) in /etc/rc.local like this

sudo /opt/openhab/start.sh &

Qtronik (author)2015-08-30

the god way to iinstall it :

https://github.com/openhab/openhab/wiki/Linux---OS-X

chris6666 (author)2015-07-17

Hi, do I have to have root privilege? I've a permission denied when I try to write distribution 1-5-1 runtime.zip. Sorry, dummy with linux...

chris6666 (author)chris66662015-07-18

Add this:

sudo chown -hR pi:pi /opt/openhab

Thanks to Robert de la Montagne !

joecam (author)2015-07-05

I am new to Linux and the Raspberry Pi, but trying desperately to get OpenHAB working and am getting this error:

HTTP ERROR 500

Problem accessing /openhab.app. Reason:

    Sitemap '"demo"' could not be found

Caused by:

org.openhab.ui.webapp.render.RenderException: Sitemap '"demo"' could not be found 
at org.openhab.ui.webapp.internal.servlet.WebAppServlet.service(WebAppServlet.java:114)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:598)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:486)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.eclipse.jetty.server.Server.handle(Server.java:350)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
at java.lang.Thread.run(Thread.java:744)

I am willing to pay someone who can tutor who help me with this, as I am trying to get an aeotec Z-stick gen5 working with a few z-wave sensors (after I can get some headway). you can contact me at joe.cammarata@gmail.com. Thanks in advance.

Joe

JobJ (author)2015-06-17

I installed Openhab and mosquitto on the pi. Can somebody help me with proceeding further? I am more interested in controlling outputs than reading data. Thanks in advance

alexleandrom (author)2015-06-02

First, congratulations for this incredible tutorial, it is very helpful

The first terminal command is wrong, the command is duplicate,
sudo apt-get updatesudo apt-get upgrade

it s just: sudo apt-get update

robert.delamontagne.1 (author)2015-03-06

Well I see some problem with the /opt/openhab files which should be allocated to the user "pi", so once the directory /opt/openhab is created the owner should be changed to pi.

Here is the sequence I did follow (based on the last NOOBS release 1.4.0 on a Raspberry Pi2 model B).

1. Verify Java version

= = = = = = = = = = =

java -version

#java version "1.8.0"

#Java(TM) SE Runtime Environment (build 1.8.0-b132)

#Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode)

if not OK see https://github.com/openhab/openhab/wiki/Apt-Repository

2. Install OpenHab by following step 1

= = = = = = = = = = = = = = = = = = =

See https://www.instructables.com/id/OpenHAB-on-Raspberry-Pi/

2.1 Find the last Openhab distribution

- - - - - - - - - - - - - - - - - - - -

https://github.com/openhab/openhab/releases/vx.y.z/distribution-x.y.z-rutime

2.2 Summary of the actions

- - - - - — - - - - - - -

sudo mkdir /opt/openhab

sudo chown -hR pi:pi /opt/openhab # changing the directory owner here will avoid a lot of pain!

wget https://github.com/openhab/openhab/releases/download/v1.6.2/distribution-1.6.2-runtime.zip

unzip distribution-1.6.2-runtime.zip

rm distribution-1.6.2-runtime.zip

cd addons

wget https://github.com/openhab/openhab/releases/download/v1.6.2/distribution-1.6.2-addons.zip

unzip distribution-1.6.2-addons.zip

rm distribution-1.6.2-addons.zip

cd /opt/openhab

cp configurations/openhab_default.cfg configurations/openhab.cfg

wget https://github.com/openhab/openhab/releases/download/v1.6.2/distribution-1.6.2-demo-configuration.zip

unzip distribution-1.6.2-demo-configuration.zip

## Archive: distribution-1.6.2-demo-configuration.zip

## replace addons/org.openhab.binding.http-1.6.2.jar? [y]es, [n]o, [A]ll, [N]one, [r]ename: A

rm distribution-1.6.2-demo-configuration.zip

chmod +x start.sh

./start.sh

2.3 Check connection

- - - - - - - - - - -

http://<host IP>:8080/openhab.app?sitemap=demo

DriesD (author)2015-03-03

This is a great guide, there are however some small errors that you could improve on:
"sudo apt-get updatesudo apt-get upgrade" needs to be
"sudo apt-get update ; sudo apt-get upgrade".
Directory /opt/openhab is owned by root, so "wget" needs to be "sudo wget" and :
"cd /opt/openhabsudo
unzip distribution-1.5.1-runtime.zip"
needs to be
"cd /opt/openhab
sudo unzip distribution-1.5.1-runtime.zip"

"rm" needs to be "sudo rm"

Just some minor details... :-)

shedzong (author)2015-01-19

Thanks for this Arizno. I followed these steps and got "update-rc.d: using dependency based boot sequencing" returned from the last command, which I think is OK. I rebooted the pi but I don't see openHAB running with "ps -ef" command. Any suggestions? openHAB is installed in /opt/openhab. I'm using pi as the user. Thanks, Peter

NémethA (author)shedzong2015-03-01

Dear shedzong,

Did you fint the solution? I have the same issue.

I used sudo chown -hR pi:pi /opt/openhab, so configuration files owner & group is pi. sudo chmod a+x /etc/init.d/openhab runs without any problem.

/etc/init.d/openhab file's owner & group is root

Any idea why it doesn't start automatically?

JamesK10 (author)2015-02-04

Excellent write up! Just enough gotchas to make you think. Went through several other tutorials via the web to no avail, yours worked first time . . . until the auto-start. Your making me think . . . some more.

deven_pillay (author)2015-01-02

Hi , When I do ./start.sh I get stuff like this below: What am I doing wrong?

java.io.IOException: Cannot write log directory /opt/openhab/logs
at org.eclipse.jetty.util.RolloverFileOutputStream.setFile(RolloverFileOutputStream.java:213) ~[org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
at org.eclipse.jetty.util.RolloverFileOutputStream.<init>(RolloverFileOutputStream.java:160) ~[org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
at org.eclipse.jetty.server.NCSARequestLog.doStart(NCSARequestLog.java:642) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59) [org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:139) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59) [org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59) [org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
at org.eclipse.jetty.server.Server.doStart(Server.java:262) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59) [org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
at org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper.start(ServerInstanceWrapper.java:166) [org.eclipse.jetty.osgi.boot_8.1.3.v20120522.jar:8.1.3.v20120522]

2015-01-02 22:38:48.411 [INFO ] [.b.sonos.internal.SonosBinding] - Querying the network for any other Sonos device
2015-01-02 22:38:50.716 [INFO ] [t.AbstractSocketChannelBinding] - The maximum buffer will be set to the default value of 1024
2015-01-02 22:38:50.720 [INFO ] [t.AbstractSocketChannelBinding] - The interval to retry connection setups will be set to the default value of 5
2015-01-02 22:38:50.725 [INFO ] [t.AbstractSocketChannelBinding] - The cron job to reset connections will be set to the default value of 0 0 0 * * ?
2015-01-02 22:38:50.746 [INFO ] [t.AbstractSocketChannelBinding] - The setting to queue write operation until a channel gets connected will be set to the default value of true
2015-01-02 22:38:50.748 [INFO ] [t.AbstractSocketChannelBinding] - The port to listen for incoming connections will be set to the default value of 0
2015-01-02 22:38:50.751 [INFO ] [t.AbstractSocketChannelBinding] - The setting to share channels within an Item will be set to the default value of true
2015-01-02 22:38:50.758 [INFO ] [t.AbstractSocketChannelBinding] - The setting to share channels between the items with the same direction will be set to the default value of true
2015-01-02 22:38:50.761 [INFO ] [t.AbstractSocketChannelBinding] - The setting to share channels between directions will be set to the default value of true
2015-01-02 22:38:50.769 [INFO ] [t.AbstractSocketChannelBinding] - The setting to use address masks for incoming connections will be set to the default value of true
2015-01-02 22:38:50.796 [INFO ] [t.protocol.internal.TCPBinding] - The maximum time out for blocking write operations will be set to the default vaulue of 3000
2015-01-02 22:38:50.799 [INFO ] [t.protocol.internal.TCPBinding] - The blocking nature of read/write operations will be set to the default vaulue of false
2015-01-02 22:38:50.803 [INFO ] [t.protocol.internal.TCPBinding] - The preamble for all write operations will be set to the default vaulue of
2015-01-02 22:38:50.802 [INFO ] [.service.AbstractActiveService] - TCP Refresh Service has been started
2015-01-02 22:38:50.808 [INFO ] [t.protocol.internal.TCPBinding] - The postamble for all write operations will be set to the default vaulue of

2015-01-02 22:38:50.814 [INFO ] [t.protocol.internal.TCPBinding] - Updating states with returned values will be set to the default vaulue of true
2015-01-02 22:38:50.839 [INFO ] [t.protocol.internal.TCPBinding] - The characterset will be set to the default vaulue of ASCII
2015-01-02 22:38:51.206 [INFO ] [.service.AbstractActiveService] - FritzBox refresh Service has been started
2015-01-02 22:38:52.498 [ERROR] [b.b.i.BTDeviceDiscoveryService] - Error while initializing local bluetooth device.
javax.bluetooth.BluetoothStateException: BlueCove com.intel.bluetooth.BluetoothStackBlueZ|com.intel.bluetooth.BluetoothStackBlueZDBus not available
at com.intel.bluetooth.BlueCoveImpl.loadStackClass(BlueCoveImpl.java:356) ~[na:na]
at com.intel.bluetooth.BlueCoveImpl.detectStack(BlueCoveImpl.java:447) ~[na:na]
at com.intel.bluetooth.BlueCoveImpl.access$500(BlueCoveImpl.java:69) ~[na:na]
at com.intel.bluetooth.BlueCoveImpl$1.run(BlueCoveImpl.java:1044) ~[na:na]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0]
at com.intel.bluetooth.BlueCoveImpl.detectStackPrivileged(BlueCoveImpl.java:1042) ~[na:na]
at com.intel.bluetooth.BlueCoveImpl.getBluetoothStack(BlueCoveImpl.java:1035) ~[na:na]
at javax.bluetooth.LocalDevice.getLocalDeviceInstance(LocalDevice.java:75) ~[na:na]
at javax.bluetooth.LocalDevice.getLocalDevice(LocalDevice.java:95) ~[na:na]
at org.openhab.binding.bluetooth.internal.BTDeviceDiscoveryService.run(BTDeviceDiscoveryService.java:113) ~[na:na]

2015-01-02 22:40:10.082 [INFO ] [.b.knx.internal.bus.KNXBinding] - Calimero library version 2.2.0-alpha
2015-01-02 22:40:11.774 [INFO ] [.w.i.api.WithingsAuthenticator] - #########################################################################################
2015-01-02 22:40:11.777 [INFO ] [.w.i.api.WithingsAuthenticator] - # Withings Binding needs authentication.
2015-01-02 22:40:11.779 [INFO ] [.w.i.api.WithingsAuthenticator] - # Execute 'withings:startAuthentication' on OSGi console.
2015-01-02 22:40:11.781 [INFO ] [.w.i.api.WithingsAuthenticator] - #########################################################################################
2015-01-02 22:40:14.467 [INFO ] [.b.s.internal.SamsungAcBinding] - active
2015-01-02 22:40:20.053 [ERROR] [.o.m.c.i.folder.FolderObserver] - An unexpected exception has occured

java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.xtext.resource.XtextResourceSet$1
at org.eclipse.xtext.resource.XtextResourceSet.getURIConverter(XtextResourceSet.java:170) ~[na:na]
at org.eclipse.xtext.resource.XtextResourceSet.getResource(XtextResourceSet.java:136) ~[na:na]
at org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:23) ~[na:na]
at org.openhab.model.core.internal.ModelRepositoryImpl.getResource(ModelRepositoryImpl.java:152) ~[na:na]
at org.openhab.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:70) ~[na:na]
at org.openhab.model.core.internal.folder.FolderObserver.checkFolder(FolderObserver.java:142) ~[na:na]
at org.openhab.model.core.internal.folder.FolderObserver.run(FolderObserver.java:99) ~[na:na]

IliaI (author)deven_pillay2015-01-16

I had this too. Reboot fixed the problem.

JoshW3 (author)deven_pillay2015-01-15

I'm getting the same errors as Deven. Any idea how to fix this?

dave.field.121 (author)2015-01-03

Had issues with the formatting of the code on the last page but sorted that with a quick google. Thanks for the nice guide

deven_pillay (author)2015-01-02

Hi Guys, muchas gracias - solved

Deven
sir2optimus (author)2014-12-18

I have a litte porblem putting the script in boot.

I created a Folder (mkdir /etc/init.d/openhab). Next I created a file (sudo nano /etc/init.d/openhab) and filled it with the code. But now I have to save it.

So I pressed ^X and I got asked to fill in a name.

How should I name it and with wich ending?

Thank you for your help and for the Instruction :)

Arizno (author)sir2optimus2014-12-21

Your question brought up a good point. You do not need to make a directory called openhab. Because when you "sudo nano" you are actually creating a file called "openhab". Upon saving the file it you are saving the file with that same name "openhab". I will remove that part. So to answer your qustion the file should be named "openhab". Make sure to erase that directory and simply save it as a file in the "init.d" directory. Sorry and thank you for your question.

rfmdelgado (author)2014-12-05

Hi, the code you say we should add... isn't there any readable version? or just copy and past one long line of code...? thanks

Arizno (author)rfmdelgado2014-12-05

Yes there is a readable version right here:
https://github.com/openhab/openhab/wiki/Samples-Tricks#how-to-configure-openhab-to-start-automatically-on-linux

The reason its all one line is to get rid of any ASCII characters that the web might add. Once you review the readable version and feel comfortable you can copy and paste the single line or try and copy it from the readable version. As long as no ASCII character are added you should be fine.

electronichamsters (author)2014-11-25

Thanks for putting this up! I love openhab. I think it'll become more popular as more people find out what its capable of. Instructables like these will help it along.

hey thanks, i learned of openhab from you by way of your blog. The thanks goes to you.

sk8nmike (author)2014-11-14

I'm using Raspbian on my pi. When I try to download the runtime or addons zip files I get an error Cannot write to "distribution-1.5.1-runtime.zip (Permission denied)

camblonie (author)sk8nmike2014-11-14

Put "sudo" in front of the line to execute the command as a "super user".

ibenkos (author)2014-11-13

So smart idea! Thanks for shearing :)

seamster (author)2014-11-12

This is a great guide. Thank you for sharing this, and all the things you learned along the way. This will be very helpful to a lot of people, no doubt!

About This Instructable

229,320views

262favorites

License:

Bio: I am a life long biz owner. I've been fortunate enough to have a successful business and a fun life.
Add instructable to: