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
1. make sure you’re Rpi is completely up to date
#: sudo apt-get update #: sudo apt-get upgrade
* 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
#: sudo mkdir /opt/openhab
in here we will get the software needed.
#: cd /opt/openhab
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:
/opt/openhab#: sudo wget https://github.com/openhab/openhab/releases/download/v1.6.1/distribution-1.6.1-runtime.zip /opt/openhab#: sudo wget https://github.com/openhab/openhab/releases/download/v1.6.1/distribution-1.6.1-addons.zip /opt/openhab#: sudo wget https://github.com/openhab/openhab/releases/download/v1.6.1/distribution-1.6.1-demo-configuration.zip
4. unzip the core (runtime)
/opt/openhab#: sudo unzip https://github.com/openhab/openhab/releases/download/v1.6.1/distribution-1.6.1-runtime.zip
This will unzip all the files in the directory
5. unzip the addons
First go to the directory addons:
#: cd /opt/openhab/addons
/opt/openhab/addons#: sudo unzip https://github.com/openhab/openhab/releases/download/v1.6.1/distribution-1.6.1-addons.zip
** 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)
#: cd /opt/openhab /opt/openhab#: sudo unzip 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
7. Time to clean up the installation zip files:
#: sudo rm /opt/openhab/distribution-1.6.1-runtime.zip /opt/openhab/distribution-1.6.1-demo-configuration.zip /opt/openhab/addons/distribution-1.6.1-addons.zip
8. by default the start script of openhab isn’t executable. So time to fix that.
#: sudo chmod +x /opt/openhab/start.sh
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
/home/pi#: sudo wget https://www.element14.com/community/servlet/JiveServlet/download/38-152207/openhab.zip
unzip the file to a new directory
/home/pi#: sudo unzip openhab.zip -d openhab_startscript
Time to move the openhab.sh script to the /etc/init.d/ directory
/home/pi#: sudo cp openhab_startscript/openhab.sh /etc/init.d
The file has to have the right permissions to be executable
#: chmod +x /etc/init.d/openhab.sh
Update the rc.d to be able to use the script on reboot
#: sudo update-rc.d openhab.sh defaults
10. usage openhab start script
you can use these commands to run it manually
#: sudo /etc/init.d/openhab.sh start #: sudo /etc/init.d/openhab.sh stop #: sudo /etc/init.d/openhab.sh restart
You can use the one below to check the status of openhab
#: sudo /etc/init.d/openhab.sh status
example manual reboot of openhab:
#: sudo /etc/init.d/openhab.sh restart
[ 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
#: tail -f /opt/openhab/logs/events.log #: tail -f /opt/openhab/logs/openhab.log
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.
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)
pi@rpi /etc/init.d $ sudo update-rc.d openhab.sh defaults
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
Fix your locale settings.
#: sudo locale -a // to check your current locale settings #: locale -a
So yes. i don’t have the NL settings in it. edit the file below and comment out the nl_NL.UTF-8 line
#: sudo vi /etc/locale.gen // to edit the locale settings file
In my case i commented out the nl_NL.UTF-8 line and save the file
Now its time to rebuild the locale settings
#: sudo /usr/sbin/locale-gen
Generating locales (this might take a while)…
after this when you set the command again, the errors should be fixed
#: sudo update-rc.d openhab.sh defaults