Tuesday, March 19, 2024

Install OpenHAB 2.0.x on Raspberry Pi (on Debian 9 – Stretch)

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

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

This HowTo prefers config files and console commands and less GUI actions, so its maybe not for starters.

1.) Install Raspberry OS (Stretch light / Debian 9) as written here. Then connect to it via SSH.

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

If this is a new Raspberry OS installation you can put a file names “SSH” on the SD card to enable SSH as written here.

2.) Update environment

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

3.) Configure Raspberry Pi OS

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

sudo dpkg-reconfigure tzdata

3b.) run the config

sudo raspi-config

and then change the hostname and in the advanced options “Expand Disk” to the maximum via “Expand Filesystem”.

3c.) then Reboot the OS.

4.) Once rebooted we need to install java (Oracle JDK)

4a.) switch to root via

sudo -s

4b.)

apt-get install dirmngr

4c.)

To install Oracle java we can use Webupd repository that is made for Ubuntu, but it also works for Raspbian (which is based on Debian). To install Java run the following commands (line by line):

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

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

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

java -version

5.) Install OpenHAB (at the moment version 2.0.x) as mentioned here

5a.) make sure that wget & encrypted transport plugins is installed via:

apt-get install wget apt-transport-https

5b.) Install the pgp key

wget -qO – ‘https://bintray.com/user/downloadSubjectPublicKey?username=openhab’ | apt-key add –

5c.) Add OpenHAB to our repository list

echo “deb https://dl.bintray.com/openhab/apt-repo2 stable main” > /etc/apt/sources.list.d/openhab2.list

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

apt-get update

5e.) Install OpenHAB

sudo apt-get install openhab2

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

– configuration will be in “/etc/openhab2”

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

We can start it now via:

sudo /bin/systemctl start openhab2.service

5f.) Now we will configure OpenHAB so that is runs during startup

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable openhab2.service

It might now a good idea to start creating a backup from the whole configuration now. To perform that power off the PI and create a backup from the SDCard.

6.) If we open now the website http://<ip-address>:8080 in a browser we should see the OpenHAB default start page. For starters, the OpenHAB documentation recommend a click on the “Standard” package. This will install the “Paper UI” (here you can install add-ons, discover and configure things etc), the “Basic UI” (here you can have a look at your created sitemaps – we’ll get back to this later), and the Habpanel (here you can create dynamic dashboards for your things). Once you clicked on “Standard”, openHAB will install the packages and afterwards take you to the start page.

7.) Now we can install some bindings. To do that perform the following steps

7a.) Login on the pi

7b.) As openHAB2 uses Apache Karaf (more infos here) we need to connect to the console via:

ssh -p 8101 openhab@localhost

As this should be the first time if the howto is followed the following prompt will come up:

The authenticity of host ‘[localhost]:8101 ([127.0.0.1]:8101)’ can’t be established.
RSA key fingerprint is 77:77:77:77:77:77:77:77:77:77:77:77:77:77:77:77.
Are you sure you want to continue connecting (yes/no)?

Enter yes to proceed and then you should get the following

Warning: Permanently added ‘[localhost]:8101’ (RSA) to the list of known hosts.
Password authentication
Password:

The default username/password is openhab:habopen, so enter habopen at the password prompt to login

After successful connection and authentication, the console will appear:

__ _____ ____
____ ____ ___ ____ / / / / | / __ )
/ __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __ |
/ /_/ / /_/ / __/ / / / __ / ___ |/ /_/ /
\____/ .___/\___/_/ /_/_/ /_/_/ |_/_____/
/_/ 2.3.0
Release Build

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown openHAB.

openhab>

7c.) To find out what features are already installed and which one can be installed we could enter the following now (more infos here):

feature:list

or

bundle:list -s

7d.)

With the following command you can install some features (here are some example I use):

Astro Binding:
feature:install openhab-binding-astro

Exec Binding:
feature:install openhab-binding-exec

JDBC Persistence MySQL
feature:install openhab-persistence-jdbc-mysql

NTP Binding:
feature:install openhab-binding-ntp

8.) Now you can start building your configuration.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Stay Connected

35FollowersFollow
- Advertisement -

Latest Articles