I wanted to install OpenHab 2 on my RPI 4 which is running the latest Raspberry Pi Desktop. But I was missing Java 8 which is a prerequisite and unfortunately not available anymore as a stable version, for Debian 10, due to a security issue.
Click to Read More
First, here is the version of Raspberry Pi Desktop I have:
$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
Trying to install Java 8 SDK was resulting in errors like:
$ sudo apt-get install openjdk-8-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package
Or like:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package openjdk-8-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
openjdk-8-jdk-headless
E: Package 'openjdk-8-jdk' has no installation candidate
My Package sources were:
deb http://ftp.debian.org/debian/ buster main contrib non-free
deb http://security.debian.org/ buster/updates main contrib non-free
deb http://ftp.debian.org/debian/ buster-updates main contrib non-free
The solution was to add a new source with the ‘unstable’ arm-hf packages in /etc/apt/sources.list.d/raspi.list (‘sid’ is the codename for unstable):
$ echo 'deb http://ftp.debian.org/debian sid main' | sudo tee -a /etc/apt/sources.list.d/
Next, do:
$ sudo apt-get update
$ sudo apt install gcc-8-base
$ sudo apt-get install openjdk-8-jdk
NB.: without installing gcc-8-base, you would get an error like this :
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libc6-dev : Breaks: libgcc-8-dev (< 8.4.0-2~) but 8.3.0-6+rpi1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
Now, you can install OpenHab 2:
$ wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add -
$ sudo apt-get install apt-transport-https
$ echo 'deb https://dl.bintray.com/openhab/apt-repo2 stable main' | sudo tee /etc/apt/sources.list.d/openhab2.list
$ sudo apt-get update
If you get an error like this one:
E: The repository 'https://openhab.jfrog.io/openhab/openhab-linuxpkg unstable Release' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
Then do:
$ echo 'deb [trusted=yes] https://dl.bintray.com/openhab/apt-repo2 stable main' | sudo tee /etc/apt/sources.list.d/openhab2.list
Finally, do:
$ sudo apt-get install openhab2
$ sudo apt-get install openhab2-addons
$ sudo systemctl daemon-reload
$ sudo systemctl enable openhab2.service
$ sudo adduser openhab dialout
$ sudo adduser openhab tty
Edit /etc/default/openhab2 to add access for Java to the serial ports (ex.:for Zwave keys)
$ nano /etc/default/openhab2
EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyS0:/dev/ttyS2:/dev/ttyACM0:/dev/ttyAMA0"
It should output:
openhab2.service - openHAB 2 - empowering the smart home
Loaded: loaded (/usr/lib/systemd/system/openhab2.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2020-07-15 21:57:07 BST; 28min ago
Docs: https://www.openhab.org/docs/
https://community.openhab.org
Main PID: 26101 (java)
Tasks: 101 (limit: 4915)
Memory: 212.3M
CGroup: /system.slice/openhab2.service
└─26101 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.logdir=/var/log/openhab2 -Dfelix.cm.dir=/var/li
Jul 15 21:57:07 Helios systemd[1]: Started openHAB 2 - empowering the smart home.
As far as I am concerned, I share via smb the various folders
Edit /etc/samba/smb.conf
$ sudo nano /etc/samba/smb.conf
[openHAB2-userdata]comment=openHAB2 userdata
path=/var/lib/openhab2
browseable=Yes
writeable=Yes
only guest=no
public=no
create mask=0777
directory mask=0777
[openHAB2-conf]comment=openHAB2 site configuration
path=/etc/openhab2
browseable=Yes
writeable=Yes
only guest=no
public=no
create mask=0777
directory mask=0777
[openHAB2-logs]comment=openHAB2 logs
path=/var/log/openhab2
browseable=Yes
writeable=Yes
only guest=no
public=no
create mask=0777
directory mask=0777
[openHAB2-backups]comment=oepnHAB2 backups
path=/var/lib/openhab2/backups
browseable=Yes
writeable=Yes
only guest=no
public=no
create mask=0777
directory mask=0777
Restart the Samba service:
$ sudo systemctl restart smbd.service
Start openHab with:
$ sudo systemctl start openhab2.service
$ sudo systemctl status openhab2.service
It can take 15′ to be initialized, but soon you should be able to access openHab on your RPI on port 8080!
Do a backup with:
$ sudo ./usr/share/openhab2/runtime/bin/backup
Restore a backup with:
$ sudo systemctl stop openhab2.service
$ sudo ./usr/share/openhab2/runtime/bin/restore /var/lib/openhab2/backups/openhab2-backup-....
$ sudo systemctl start openhab2.service
It will take long minutes to restart!
More details about installing openHAb on Linux on the official page.
Et voilà!
Leave a Reply