Thursday, June 13, 2024

Install OpenHAB 1.x on Raspberry Pi

Abstract: In this short HowTo we will explain how you can install OpenHAB 1.x on an Raspberry PI

This HowTo didn´t covered security topics e.g. using SSL or setting up a user and password for the remote access!

1.) Install Raspberry OS (Jessie light) [Version May 2016 is used in this howto]

I use a Transcend SDHC Ultimate 8GB, UHS-I/Class 10 (TS8GSDHC10U1) SD card here

2.) Update environment

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

3.) Configure Raspberry Pi OS

3a.) run the config

sudo raspi-config

and then “Expand Disk”.

3b.) Change the hostname

3c.) Make sure here you use the correct date, time and timezone. Change that via:

sudo dpkg-reconfigure tzdata

if needed, then Reboot the OS.

4.) Once rebooted we need to install java

4a.) switch to root via

sudo -s

4b.) run the following commands (line by line):

echo “deb trusty main” > /etc/apt/sources.list.d/webupd8team-java.list
echo “deb-src trusty main” >> /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv –keyserver hkp:// –recv-keys EEA14886
apt-get update
apt-get install oracle-java8-installer

When you are prompt to accept the license, accept it.

4c.) Once installed you can check it via:

java -version

5.) Install OpenHAB (at the moment version 1.8.3)

5a.) make sure wget is installed via:

apt-get install wget

5b.) Install the pgp key

wget -qO – ‘’ | apt-key add –

5c.) Add OpenHAB to our repository list

echo “deb stable main” > /etc/apt/sources.list.d/openhab.list

5d.) now we update our pakage DB via:

apt-get update

5e.) Install OpenHAB

apt-get install openhab-runtime

This will install OpenHAB in “/usr/share/openhab”. This caused the following:

– configuration will be in “/etc/openhab”

– script will be in “/etc/openhab/configuration/scripts”

– the logfiles will be in “/var/log/openhab”

– Icons will be in “/usr/share/openhab/webapps/images”

Map transformation will be in “/etc/openhab/configurations/transform”

– Persistent items “/etc/openhab/configurations/persistence”

– The Start/stop script will be “/etc/init.d/openhab”

5f.) Start OpenHAB via:

systemctl start openhab

5g.) Configure OpenHAB to start automatically via:

systemctl enable openhab

6.) Install OpenHAB addons

6a.) You can check which addons you need via:

sudo apt-cache search openhab

6b.) And then install the one you need via (here are some example which are required for the tutorials on this website):

sudo apt-get install openhab-addon-binding-astro openhab-addon-binding-homematic openhab-addon-binding-exec openhab-addon-binding-ntp openhab-addon-binding-weather openhab-addon-persistence-exec openhab-addon-persistence-logging openhab-addon-persistence-mysql openhab-addon-action-mail

7.) Now we will setup a DEMO config.

7a.) Create at first a new demo sitemap via:

sudo nano /etc/openhab/configurations/sitemaps/mydemo.sitemap

and past the following content in it:

sitemap mydemo label="Hauptmenue"
  Frame {
        Group item=gOG  label="Obergeschoss"    icon="firstfloor"
        Group item=gEG  label="Erdgeschoss"     icon="groundfloor"

After that close the editor and save the file.

7b.) create an items file via:

sudo nano /etc/openhab/configurations/items/mydemo.items

and past the following content in it:

// Gruppen
Group gEG     // Gruppe Erdgeschoss
Group gOG     // Gruppe Obergeschoss
Group OG_Schlafzimmer    "Schlafzimmer"    <bedroom>    (gOG)
Group OG_Kinderzimmer1    "Kinderzimmer1"    <boy1>        (gOG)
Group OG_Kinderzimmer2    "Kinderzimmer2"    <child2>    (gOG)
Group OG_Bad        "Bad"        <bath>        (gOG)
Group EG_Kueche        "Kueche"     <kitchen>    (gEG)
Group EG_Esszimmer    "Esszimmer"     <child1>     (gEG)
Group EG_WC        "WC"        <bath>        (gEG)
Group EG_Wohnzimmer    "Wohnzimmer"    <sofa>        (gEG)
Group EG_Abstellraum    "Abstellraum"    <wardrobe2>    (gEG)
Switch Licht_OG_Kinderzimmer1    "Licht Kinderzimmer1"    (OG_Kinderzimmer1)
Switch Licht_OG_Kinderzimmer2    "Licht Kinderzimmer2"    (OG_Kinderzimmer2)
Switch Licht_OG_Bad_Spiegel    "Licht Spiegelschrank"    (OG_Bad)
Switch Licht_EG_Kueche        "Licht Kueche"        (EG_Kueche)
Switch Licht_EG_Esszimmer    "Licht Esszimmer"    (EG_Esszimmer)
Switch Licht_EG_WC        "Licht WC"        (EG_WC)
Switch Licht_EG_Abstellraum    "Licht Abstellraum"    (EG_Abstellraum)
Dimmer Licht_OG_Schlafzimmer    "Licht Schlafzimmer"    (OG_Schlafzimmer)
Dimmer Licht_OG_Bad        "Licht Bad"        (OG_Bad)
Dimmer Licht_EG_Wohnzimmer    "Licht Wohnzimmer"    (EG_Wohnzimmer)

After that close the editor and save the file.

8.) Test if it works. To do that visit the following site http://<ip-address>:8080/ with your browser. You should see the DEMO sitemap here.

9.) Download the OpenHAB App, connect your phone to the same LAN (e.g. via WLAN where the Raspberry Pi exists in) and configure the app with the URL http://<ip-address>:8080 to check if the app is working as well. You should see the DEMO sitemap here.

10.) The last step is to copy the default config (openhab_default.cfg) so that we can adjust it later one and also ensure it will not be overwritten. This can be done via:

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

11.) To allow OpenHAB to run Scripts (Bash, Phyton, …), we need to create a folder (based on infos from here).

11a.) beginning from the root go to opt

cd opt

11b.) create a new folder for scripts via:

sudo mkdir my-openhab-scripts

11c.) Change the owner to openhab via

sudo chown openhab: my-openhab-scripts

12.) If everything is running you can shutdown the device and create a backup copy with Win32DiskImager.


Depending on your config you might wish to shutdown HDMI:

/opt/vc/bin/tvservice –off

which will save some power

Related Articles


Please enter your comment!
Please enter your name here

Stay Connected

- Advertisement -

Latest Articles