OpenHAB Concepts This note was prepared to gain a superficial understanding of some basic concepts in openHAB 2.5. Practice, practice Some key steps to consider during the introductory openHAB journey: 1. Install openHAB 2. If you already own a smart device, search the addons for the brand or technology used by that device (or simply browse the list of add-ons for any technologies or services you may recognize) 3. Install a binding (in openHAB) 4. Define a thing 5. Add a channel to the thing if not created by the binding 6. Define an item 7. Link the channel to your item 8. Establish a sitemap Installation Prerequisites Zulu From the official web site: Azul® Zulu® is a Java Development Kit (JDK), and a compliant implementation of the Java Standard Edition (SE) specification that contains all the Java components needed to build and run Java SE applications. Zulu has been verified by passing all tests of the OpenJDK Community Technology Compatibility Kit (TCK) as available for each respective Java SE version. Download Zulu CommunityTM The only downloads for Java 8 (LTS) ARM 64-bit architecture are the following (as of 2019-12-16): • v 8.42.0.195 – 8u232 (ARM 64-bit armv5/v6/v7/v8 • v 8.40.0.179 – 8u222-b10 (ARM 64-bit armv8) Installation on Linux Using the Zulu TAR.GZ File Before installing Zulu, complete the tasks in the section, Preparing the Zulu Installation Platform. 1. Download the installation package to a preferred location on the server. For example: $ sudo mkdir /usr/lib/jvm # if necessary $ cd /usr/lib/jvm/ $ wget https://cdn.azul.com/zulu-embedded/bin/zulu8.42.0.195-ca-jdk1.8.0_232-linux_aarch64.tar.gz 2. Expand the downloaded .zip file. $ tar -xzvf zulu8.42.0.195-ca-jdk1.8.0_232-linux_aarch64.tar.gz All Zulu files for the OpenJDK are expanded into appropriate folders relative to the / subfolder. For example: /usr/lib/jvm/zulu8.42.0.195-ca-jdk1.8.0_232-linux_aarch64 The preferred location for JAVA_HOME or any system variable is the file /etc/environment. • Edit /etc/environment file with elevated privileges and insert the following line: JAVA_HOME=/usr/lib/jvm/zulu8.42.0.195-ca-jdk1.8.0_232-linux_aarch64 and after the existing PATH statetement, insert the following line: PATH=$PATH:$JAVA_HOME/bin The contents of the file /etc/environment may be similar to that shown below: JAVA_HOME=/usr/lib/jvm/zulu8.42.0.195-ca-jdk1.8.0_232-linux_aarch64 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" PATH=$PATH:$JAVA_HOME/bin • Use the command to load the variables, by running the following command: $ source /etc/environment • Check the newly defined variable with the following command: $ echo $JAVA_HOME • Test the version numbers with the following commands: $ java -version openjdk version "1.8.0_232" OpenJDK Runtime Environment (build 1.8.0_232-8u232-b09-0ubuntu1.1-b09) OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode) $ $JAVA_HOME/bin/java -version openjdk version "1.8.0_232" OpenJDK Runtime Environment (Zulu8.42.0.195-CA-linux_aarch64) (build 1.8.0_232-b195) OpenJDK 64-Bit Server VM (Zulu8.42.0.195-CA-linux_aarch64) (build 25.232-b195, mixed mode, Evaluation) $ $JAVA_HOME/bin/javac -version javac 1.8.0_232 ubuntu@raspbari27:/etc$ https://vitux.com/how-to-setup-java_home-path-in-ubuntu/ Options There are three options for the installation using: 1. The openHABian 2. A package repository (e.g. apt) 3. Manual commands This document is limited to illustrating the second option. Repository key • Install the repository key for openHAB 2 Bintray: wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add - The successful command response is OK. HTTPS protocol • Use HTTPS protocol for apt operations: sudo apt install apt-transport-https Typical output is shown below: Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: apt-transport-https 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 1704 B of archives. After this operation, 157 kB of additional disk space will be used. Get:1 http://ports.ubuntu.com/ubuntu-ports eoan/universe arm64 apt-transport-https all 1.9.4 [1704 B] Fetched 1704 B in 1s (2868 B/s) Selecting previously unselected package apt-transport-https. (Reading database ... 67696 files and directories currently installed.) Preparing to unpack .../apt-transport-https_1.9.4_all.deb ... Unpacking apt-transport-https (1.9.4) ... Setting up apt-transport-https (1.9.4) ... Stable release Append the reference to sources list: • Use the latest official release: $ echo 'deb https://dl.bintray.com/openhab/apt-repo2 stable main' | sudo tee /etc/apt/sources.list.d/openhab2.list The entry will be echoed back to the terminal session as follows: deb https://dl.bintray.com/openhab/apt-repo2 stable main Update package index • Update the package index: $ sudo apt update The presence of the following two lines will confirm successful completion of the command: Get:10 https://dl.bintray.com/openhab/apt-repo2 stable Release.gpg [821 B] Get:11 https://dl.bintray.com/openhab/apt-repo2 stable/main arm64 Packages [2100 B] Install package and add-ons • Install the package and associated add-on solutions: $ sudo apt install openhab2 openhab2-addons Set service operations Establish daemon for the solution with the following commands: $ sudo systemctl start openhab2.service $ sudo systemctl status openhab2.service ● openhab2.service - openHAB 2 - empowering the smart home Loaded: loaded (/lib/systemd/system/openhab2.service; disabled; vendor preset Active: active (running) since Thu 2019-12-19 01:36:34 UTC; 25s ago Docs: https://www.openhab.org/docs/ https://community.openhab.org Main PID: 3589 (java) Tasks: 52 (limit: 4434) CGroup: /system.slice/openhab2.service └─3589 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.con Dec 19 01:36:34 raspbari27 systemd[1]: Started openHAB 2 - empowering the smart lines 1-11/11 (END) $ sudo systemctl daemon-reload $ sudo systemctl enable openhab2.service Synchronizing state of openhab2.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable openhab2 Created symlink /etc/systemd/system/multi-user.target.wants/openhab2.service → /lib/systemd/system/openhab2.service. Validate connectivity After the services are in operation, use the following step to validate that openHAB is up and running! • Navigate to the dashboard at http://raspbari27.parkcircus.org:8080/ https://www.openhab.org/docs/tutorial/1sttimesetup.html Beginner’s tutorial • At the Welcome page, choose Standard package Console access The access to openHAB using the command line is: $ openhab-cli console with the default credential pair as openhab:habopen and the username automatically applied. The command to end the session is logout. openhab> logout $ References https://www.openhab.org/docs/ Zulu Community Support Replies https://community.openhab.org/t/rpi4-ubuntu-server-19-10-1-cannot-load-home-page/87989/2 Benjy Ben Clark Maintainer December 19 The logs should be able to provide some indication: /var/log/openhab2/openhab.log shows logs created by openHAB. But you can also use the command: sudo journalctl -u openhab2 -b to see some messages created when trying to start openHAB. It’s likely that the LAMP configuration is using port 8080. You can change openHAB’s ports by editing and un-commenting the appropriate lines in etc/default/openhab2. You’ll need to restart openhab2 for the changes to take affect. $ sudo netstat -anp | grep apache tcp6 0 0 :::80 :::* LISTEN 1583/apache2 $ $ cat /var/log/openhab2/openhab.log 2019-12-19 01:37:20.949 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.50.180:8080 2019-12-19 01:37:21.016 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.50.180:8443 2019-12-19 01:37:22.041 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007 2019-12-19 01:37:27.754 [INFO ] [.dashboard.internal.DashboardService] - Stopped Dashboard 2019-12-19 02:17:12.276 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007 $ $ cat /var/log/openhab2/openhab.log 2019-12-19 01:37:20.949 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.50.180:8080 2019-12-19 01:37:21.016 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.50.180:8443 2019-12-19 01:37:22.041 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007 2019-12-19 01:37:27.754 [INFO ] [.dashboard.internal.DashboardService] - Stopped Dashboard 2019-12-19 02:17:12.276 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007 $ openhab> log:tail 02:17:12.276 [INFO ] [rthome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007 openhab> logout ubuntu@raspbari27:~$ sudo systemctl start openhab2.service ubuntu@raspbari27:~$ sudo systemctl status openhab2.service ● openhab2.service - openHAB 2 - empowering the smart home Loaded: loaded (/lib/systemd/system/openhab2.service; enabled; vendor preset: Active: active (running) since Thu 2019-12-19 02:16:38 UTC; 18h ago Docs: https://www.openhab.org/docs/ https://community.openhab.org Main PID: 1387 (java) Tasks: 99 (limit: 4434) CGroup: /system.slice/openhab2.service └─1387 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.con Dec 19 02:16:38 raspbari27 systemd[1]: Started openHAB 2 - empowering the smart lines 1-11/11 (END) nmap scan Nmap scan report for raspbari27.parkcircus.org (192.168.50.180) Host is up (0.00028s latency). Not shown: 997 filtered ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.0p1 Ubuntu 6build1 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 3072 29:dc:a2:71:fc:d6:48:1a:3b:ec:ab:ea:1b:87:24:15 (RSA) | 256 b0:5b:4c:e1:2b:7d:1c:4c:8f:cc:ab:27:30:1d:1f:54 (ECDSA) |_ 256 b6:9b:6c:ed:fc:74:8c:28:64:c0:26:28:3a:90:08:f7 (ED25519) 80/tcp open http Apache httpd 2.4.41 ((Ubuntu)) | http-methods: |_ Supported Methods: POST OPTIONS HEAD GET |_http-server-header: Apache/2.4.41 (Ubuntu) |_http-title: Apache2 Ubuntu Default Page: It works 443/tcp closed https MAC Address: DC:A6:32:19:D7:23 (Raspberry Pi Trading) Aggressive OS guesses: Linux 2.6.32 - 3.13 (95%), Linux 2.6.22 - 2.6.36 (93%), Linux 3.10 - 4.11 (93%), Linux 2.6.39 (93%), Linux 3.10 (93%), Linux 2.6.32 (92%), Linux 3.2 - 4.9 (92%), Linux 2.6.32 - 3.10 (92%), Linux 2.6.18 (91%), Linux 3.16 - 4.6 (91%) No exact OS matches for host (test conditions non-ideal). Uptime guess: 29.636 days (since Tue Nov 19 23:47:26 2019) Network Distance: 1 hop TCP Sequence Prediction: Difficulty=259 (Good luck!) IP ID Sequence Generation: All zeros Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel TRACEROUTE HOP RTT ADDRESS 1 0.28 ms raspbari27.parkcircus.org (192.168.50.180)