Openhab installation

at the moment im using a Raspberry pi for the home automation project i started. In this tutorial i will setup a fresh install of Raspbian Debian Wheezy. on top of that an Openhab installation with automatic start script. I followed some tutorials elsewhere and created one tutorial guide of it. i assume you know how to setup a Rpi with Raspbian Wheezy. If not i will create another tutorial for that later on.

Raspberry Pi B+ 512MB
OS: Raspbian Debian Wheezy (2014-09-09)
Openhab version: 1.6.1
MicroSD: 16GB

1. make sure you’re Rpi is completely up to date

* a note when installing Rpi is to make sure you have set your locale settings. Otherwise you will get some errors when creating the automatic start script for openhab. The solution is given in the trouble shooting area though ;).

2. Create a directory for Openhab

in here we will get the software needed.

3. Time to download the needed files

Runtime: these are the core files
Addons: various addons which can be used within openhab.
Demo configuration: this can you give a good head start with openhab.it can be deleted afterwards.
make sure you are in the /opt/openhab directory:

4. unzip the core (runtime)

This will unzip all the files in the directory

5. unzip the addons
First go to the directory addons:

 

 

** NOTE. for demonstration it’s ok to copy all addons. for production its best to only add the addons you need. so keeping the addons unzipped in your home directory is best. To add an adddon you only have to copy/paste the .jar file in the /opt/openhab/addons directory and restart openhab to actually load the addon.

on reboot it can take quite some time to load all the addons. even when you only use a 10th of them.

6. unzip the demo configuration files
These will overwrite an addon. I didn’t get this notice before, but in this case i let the demo configuration overwrite an addon (http binding)

Archive:  distribution-1.6.1-demo-configuration.zip

replace addons/org.openhab.binding.http-1.6.1.jar? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
inflating: addons/org.openhab.binding.http-1.6.1.jar
inflating: addons/org.openhab.binding.ntp-1.6.1.jar
inflating: addons/org.openhab.persistence.rrd4j-1.6.1.jar
inflating: addons/org.openhab.persistence.logging-1.6.1.jar
inflating: addons/org.openhab.persistence.exec-1.6.1.jar
inflating: configurations/items/demo.items
inflating: configurations/persistence/db4o.persist
inflating: configurations/persistence/exec.persist
inflating: configurations/persistence/logging.persist
inflating: configurations/persistence/rrd4j.persist
inflating: configurations/rules/demo.rules
inflating: configurations/scripts/demo.script
inflating: configurations/sitemaps/demo.sitemap
inflating: README.TXT

7. Time to clean up the installation zip files:

8. by default the start script of openhab isn’t executable. So time to fix that.

From this point the first installation and demo configuration is done. Time to add an automatic start script for openhab. This script also makes it easier to start/stop/restart openhab

i didn’t create this script. So credits go to the writer of this topic: ( https://www.element14.com/community/community/design-challenges/forget-me-not/blog/2014/08/20/pas-home-auto-start-openhab)

9.Openhab automatic start script
download the file

unzip the file to a new directory

Time to move the openhab.sh script to the /etc/init.d/  directory

The file has to have the right permissions to be executable

Update the rc.d to be able to use the script on reboot

10. usage openhab start script

you can use these commands to run it manually

You can use the one below to check the status of openhab

example manual reboot of openhab:

[ ok ] Stopping system openhab daemon:.

[ ok ] Starting system openhab daemon:.

11. Log files
To read some logfiles of openhab you can use the commands to tail them after reboot or restart

Or just simply use cat /opt/openhab/logs/events.log / openhab.log to check the files for errors.

Reboot your rpi to check if everything is coming back up.

openhab link: https://your-rpi-ipaddress:8080/openhab.app?sitemap=demo

From here i will create some tutorials to create your own sitemap.

Trouble shooting:

A. Openhab Start Script: after i run the update.rc command i receive this error: (in my case the dutch language i haven’t set)

###

perl: warning: Setting locale failed.

perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_PAPER = “nl_NL.UTF-8”,
LC_ADDRESS = “nl_NL.UTF-8”,
LC_MONETARY = “nl_NL.UTF-8”,
LC_NUMERIC = “nl_NL.UTF-8”,
LC_TELEPHONE = “nl_NL.UTF-8”,
LC_IDENTIFICATION = “nl_NL.UTF-8”,
LC_MEASUREMENT = “nl_NL.UTF-8”,
LC_TIME = “nl_NL.UTF-8”,
LC_NAME = “nl_NL.UTF-8”,
LANG = “en_GB.UTF-8”
are supported and installed on your system.
perl: warning: Falling back to the standard locale (“C”).
update-rc.d: using dependency based boot sequencing
###

A. Solution:
Fix your locale settings.

C
C.UTF-8
en_GB.utf8
POSIX

So yes. i don’t have the NL settings in it. edit the file below and comment out the nl_NL.UTF-8 line

In my case i commented out the nl_NL.UTF-8 line and save the file

Now its time to rebuild the locale settings

Generating locales (this might take a while)…

en_GB.UTF-8… done
nl_NL.UTF-8… done

after this when you set the command again, the errors should be fixed

Credits:

– automatic Startscript Openhab: Openhab Startscript
– basic setup openhab/Rpi: Setup openhab Rpi
– openhab software: https://www.openhab.org

You may also like...

3 Responses

  1. gambituk says:

    Just had to say that this is a good walkthrough.. i’ve attempted 2 or 3 times without success.. There were a few mistakes and tripping points in this but nothing that wasn’t overcome with a little thought. Thanks for the work. i’m looking forward to the tut on making sitemap!

  2. Kevin says:

    Thanks for this! First time playing with OpenHab and wanted it to start automatically. Your script worked great for me.

Leave a Reply

Your email address will not be published. Required fields are marked *