It was time to migrate the openhab installation from the Raspberry Pi 3B to the NUC.
Before leaving the Pi a full backup is required. openhab-cli backup name_of_zipped_backup
. Details on the backup and restore process can be found in the openhab forums.
The installation starts with a fresh Debian Buster(10.4) console only install. Openhabian was added from git following the guide at https://www.openhab.org/docs/installation/openhabian.html.
sudo apt-get install git screen curl gnupg sudo git clone https://github.com/openhab/openhabian.git /opt/openhabian sudo ln -s /opt/openhabian/openhabian-setup.sh /usr/local/bin/openhabian-config
The optional Influx db for persistence and Grafana for graphs were added from the openhabian-config tool. Chronograf 1.8 was also added manually ( sudo apt-get install chronograf
) since Influx after v1.3 doesn’t support the web console anymore. Note this is from the Influx repo which is added by the openhabian-setup tool.
At this point: Openhab web interface -> http://your_ip:8080 Openhab console (ssh) -> your_ip:8101 Influx web admin (chronograf) -> http://your_ip:8888 Grafana -> http://your_ip:3000
Hopefully, at this point it’s time to restore the backup made earlier on the Pi: openhab-cli restore name_of_zipped_backup
Possible Issues
To resolve the issue of the openhab repo not being properly signed refer to the discussion in the openhab forums. You will need to execute:
wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key <strong>add</strong> -
If you encounter errors in the log file regarding RestDocs, for example, “ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing ‘openhab-misc-restdocs’
“, refer to the discussion in the forums. The secret is the second set of config files at /var/lib/openhab2/config/org/openhab/addons.config
.
If you encounter broken graphs in the Openhab UI with error messages similar to [WARN ] [org.eclipse.jetty.server.HttpChannel] - /chart
refer to the discussion in the forums. The trick here is to install fontconfig for 32 bit arch even on a 64 bit machine:
java.lang.Error: Probable fatal error:No fonts foundsudo apt-get install fontconfig:i386
. A restart of the openhab service will be required after installing fontconfig: sudo systemctl restart openhab.service
.
Remote Z-Wave
One of the main reasons openhab had stayed on the Pi so long was the location of the Pi and the Aeon Labs DSA02203-ZWUS Z-Wave Z-Stick Series 2 USB Dongle. This dongle creates /dev/ttyUSB0 for the z-wave binding. Our solution was to leave the Pi in place with the dongle and handle the serial port connection over Ethernet to the NUC. ser2net gets installed on the machine with the dongle. socat gets installed and run as a service on the openhab server machine. There is a great discussion on the in the openhab forums.
On the Pi:sudo apt-get install ser2net pico /etc/ser2net.conf3333:raw:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBITOn the NUC:sudo apt-get install socat git clone https://github.com/asaif/socat-init.git sudo cp socat-init/socat /etc/init.d/ sudo chmod +x /etc/init.d/socat sudo update-rc.d socat defaults sudo cp socat-init/defaults/socat.conf /etc/default/ sudo nano /etc/default/socat.confOPTIONS="pty,link=/dev/ttyUSB0,raw,user=openhab,group=dialout,mode=777 tcp:ip_of_the_pi:3333"sudo service socat restart
This will create /dev/ttyUSB0 on the NUC which looks like a serial device to the z-wav binding.
Final Steps
The final steps were to make sure everything that was pointing the to Pi was now pointing to the NUC.
The RFM69HCW 915MHz radio on the original openhab Pi remained in place listening to the Moteinos and sending mqtt but needed to have the destination updated. This required recompiling Gateway.c. Somehow the appropriate libraries weren’t already on the Pi for this: sudo apt-get install libmosquitto-dev libmosquittopp-dev
. The recompile then when fine: g++ Gateway.c rfm69.cpp -o Gateway -lwiringPi -lmosquitto -DRASPBERRY -DDEBUG
.
The code on the Pi sending outside temperature and humidity via mqtt from the am2315 i2c sensor needed to be recompiled to send to the proper destination: gcc piGateway.c -o piGateway -lwiringPi -lmosquitto -lam2315 -DRASPBERRY -DDEBUG
.
The Pi running the Weather Alert / SAME code needed to have the destination address updated. This is a simple change to the mqtt command line parameter in the script. The same Pi also runs the Seneye aquarium monitor code which needed an edit in suddriver.py to update the mqtt destination.
The Pi running rtl_433 for the LaCrosse weather station integration required an update to rtl_433.conf to point the mqtt data to the new destination. The same Pi also runs the as3935 Lightning detector. A quick modification to the python script to fix the mqtt destination got this back online.