Tag: OpenHab

  • How to identify the Philips Hue sensors in OpenHab ?

    When looking at the Things within OpenHab, each “Hue Motion Sensor” device appears as multiple things: the “Motion sensor xyz” itself but also a “Hue ambient light sensor i” and a “Hue temperature sensor i”. “Motion sensor xyz” is the name you gave to the device via the Philips Hue App and “i” is a sequential id which can’t be easily linked to the related “Motion sensor” device… The App Hue Essentials can help you !

    Click to Read More

    On the screenshot bellow, one can see that I have renamed the Motion Sensors into “Motion sensor Door” and “Motion sensors Entry”, within the Philips Hue App. NB.: Only the Motion sensors appears in the Philips Hue App. One doesn’t see the Temperature and Ambient Light sensors…

    In OpenHab, we see all the sensors, but the Ambient Light and Temperature sensors are not named accordingly to the related Motion sensors. Instead, the are named “Hue ambient light sensor i” and a “Hue temperature sensor i” and one has no idea which one is part of the “Motion sensor Door” or “Motion sensor Entry”:


    The App Hue Essentials is not free but is really great (opposite to Philips Hue, you can for example control devices from multiples Bridges without switching from one to the other all the time). It’s the first App I found, made for end users (and not for developers), which give access to the internal sensors of a selected device. I.e.: the other Apps list all the sensors but does not tell which sensors belongs to which device.

    One way to identify which sensor belongs to which device is to go to the Devices (1) within the App Hue Essentials, select the device (2).

    Next , select, the menu Details (1 then 2):

    In these details, you see the Identifier of the device. Here, the identifier is 13. 

    Back into OpenHab, you can now filter the list of Things on ‘:13’ and find the device. 

    That was quite useless as the name of the device is the same in OpenHab and Philips Hue… but you can see that, obviously, the “Unique ID” displayed in Hue Essentials (00:17:88:01:06:44:42:35) is not the full id displayed (0107:ecb5fa857069)..

    One can do the same to find the id of the other sensors of this device: instead of the menu “Details”, select now the menu “Temperature” or “Light Level”. One can see immediatly the name of the related sensor (Here under “Hue light sensor 1”). One can also take the menu “Detail” (1) to take note of the identifier (here under “14”) to filter for it in OpenHab’s Things list.

    The best is however to rename these sensors according to their device (The “Hue light sensor 1” could be renamed “Hue light sensor Door”), remove all of them (especially the “Motion Sensors” which were properly named otherwise,  the other sensors won’t be re-detected) and rescan for Hue’s Things in OpenHab.

    Et voilà.


  • Install Z-Stick & ConBee II on RPI/Openhabian

    Here is how to configure properly an Aeotec Z-Stick Gen5 and a Conbee II stick on a RPI 4 installed with Openhabian (running OpenHab 3)

    Click to Read More

    First, be sure that openhabian can access the serial ports. The easiest is to configure that via openhabian-config > System Settings > Serial Port:

    sudo openhabian-config 

    You can also do it with raspi-config > Interfacing Options > Serial :

    sudo apt-get install raspi-config
    sudo raspi-config

    > Would you like a login shell accessible over serial? → No
    > Would you like the serial port hardware to be enabled? → Yes


    Next, check that the sticks are well plugged with the command:


    You should see something like

    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 011: ID 1cf1:0030 Dresden Elektronik ZigBee gateway [ConBee II]
    Bus 001 Device 005: ID 0658:0200 Sigma Designs, Inc. Aeotec Z-Stick Gen5 (ZW090) – UZB
    Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

    In order to always have the USB sticks mounted on the same “port”, instead of being assigned once on /dev/ttyACM0, once on /dev/ttyACM1, … create a UDEV Rule file:

    sudo nano /etc/udev/rules.d/99-usb-serial.rules

    Type the following, using the ID of the USB sticks found above, in this file:

    SUBSYSTEM==”tty”, ATTRS{idVendor}==”0658“, ATTRS{idProduct}==”0200“, SYMLINK+=”ttyUSB-ZWave”, GROUP=”dialout”, MODE=”0666″
    SUBSYSTEM==”tty”, ATTRS{idVendor}==”1cf1“, ATTRS{idProduct}==”0030“, SYMLINK+=”ttyUSB-ZigBee”, GROUP=”dialout”, MODE=”0666″

    If you didn’t prepare openhabian for ZigBee via sudo openhabian-config > System Settings > Serial Port, grant the following access for openhab :

    sudo adduser openhab dialout
    sudo adduser openhab tty

    Now, reboot (sudo reboot) and test if symlink was created with the command :

    ls /dev/tty*

    You should see


    Add edit openhab config file to add the symlinks to the PATH variable for Java (NB: for openhab 2, the file is namge openhab2 !!):

    sudo nano /etc/default/openhab

    Search the line with EXTRA_JAVE_OPTS and modify accordingly to complete the parameter ‘Dgnu.io.rxtx.SerialPorts’:

    EXTRA_JAVA_OPTS=”-Xms192m -Xmx320m -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB-ZWave:/dev/ttyUSB-ZigBee

    Now, reboot again (sudo reboot) and install Phoscon, the application to manage the ZigBee devices. The easiest is to install it (on port 8081 as recommended) via openhabian-config > Optional Components > deCONZ:

    sudo openhabian-config

    You can also look here on the phoscon website for a manual setup

    If you have a RPI 4B, also update the WiringPI like this:

    cd /tmp
    wget https://project-downloads.drogon.net/wiringpi-latest.deb
    sudo dpkg -i wiringpi-latest.deb

    You can now open phoscon to login and search for ZigBee devices on http://<your RPI IP>:8081

    If after a reboot, this UI is not available, then enable manually the service:

    sudo systemctl enable deconz

    If you want to change the port of Phoscon, edit the parameter ‘http-port’ in this file:

    sudo nano /lib/systemd/system/deconz.service


    Finally, install the following addons (Bindings) in OpenHab :

    • “Dresden Elektronik deCONZ Binding”
    • “Z-Wave Binding”

    The ConBee gateway will be detected automatically by OpenHab and appear twice in the ‘Inbox’: once as Deconz and once as Hue (indeed, it emulates a Philips Hue Bridge). If it was not detected automatically, open the Phoscon UI > Gateway > Advanced (Gear Icon at the bottom of the page) and CLick on “Authenticat App”. Then add the Thing manually into OpenHab using the Scan button of:

    OpenHab UI > Administration > Parameters > Things > + (Add Thing) > Dresden Elektronik deCONZ Binding


    The Zwave gateway will only appear if you add it explicitly into OpenHab:

    OpenHab UI > Administration > Parameters > Things > + (Add Thing) > Z-Wave Binding > Z-Wave Serial Controller

    In the field Serial Port, type manually ‘/dev/ttyUSB-ZWave’ (without the quotes) and click ‘Create Thing’

    Wait for about 10 seconds and the gateway will soon become online.

    Et voilà.


  • RPI 4/Openhabian into an Argon One Case


    If you installed Openhabian onto an RPI hosted into an Argon Once Case, here is how to configure the Argon One.

    Click to Read More

    Install the scripts to manage to Argon One’s features:

    sudo curl https://download.argon40.com/argon1.sh | bash

    Configure the fan cooler, for example depending on the temperature, with the command:

    sudo argonone-config

    Select the option 2 and type 10 for 55 °C, 55 for 60 °C and 100 for 65 °C, meaning that the fan speed will by 10% at 55 °C, etc…


    In order to configure the Argon One to turn on automatically after a power failure, you have first to enable the i2C. The easiest is to do it with the raspi-config command, which can be installed with:

    sudo apt-get install raspi-config

    Then run it:

    sudo raspi-config

    And go to the menu “Interface option”, and select the entry “I2C” to enable the loading of the I2C kernel module.

    Now you can check that it works with the command:

    i2cdetect -y 1

    And finally set the Power-On feature with the command:

    i2cset -y 1 0x01a 0xfe


    Now, you can press the power button of the Argon One :

    • twice to reboot
    • +3 sec to shutdown and power off
    • +5 sec to force the shutdown


    Et voilà


  • How to create a recursive Timer in OpenHab3’s DSL Rule

    I wanted a DSL Script to send a notification email if a door was still opened after several checks.

    There are various options to achieve this purpose.

    Click to Read More

    A simple option could have been to use a Switch Item with an Expire Property. When the door opens, set that Switch Item to ‘ON’ and initialize a Number Item to be count how many checks will be done. When the Switch Item expires, execute a script which checks if the door is still opened. If it is not, that script ends. Otherwise, it increases the Item Number. If that Item Number is lower than the maximum checks to be done (your threshold), Set back the Switch Item to ‘ON’. Otherwise, send the notification email.

    Another option (just for fun) relies on a DSL Script with a lamdba expression which creates a Timer calling itself recursively until the door is closed or your threshold is reached. That DLS Script must be called when the Door opens.

    Here after a Number Item SensorGarageDoor_Duration is used to count the number of checks: The Item SensorGarageDoor_OpenClose is the state of the Sensor on the Door.

    val int treshold = 3
    var int attempt = 0
    // Define a Lambda Expression to check if the Door is open and if not,
    // call itself after 15 minutes to check again until a treshold of calls is reached
    val Functions$Function1 Monitor = [	Functions$Function1 recursive |
    	if (SensorGarageDoor_OpenClose.state == OPEN) {
    		logInfo("default.rules", "Monitor Opened Door")
    		createTimerWithArgument(now.plusMinutes(15), recursive, [ Functions$Function1 callMonitor |
    				var int duration = (SensorGarageDoor_Duration.state as Number).intValue + 1
    				logInfo("default.rules", "Garage Opened since " + duration.toString + " cycle(s)")
    				if (duration == treshold) {
    					logInfo("default.rules", "Notify by email that Garage still Opened after " + duration.toString + " cycles")
    					val mailActions = getActions("mail", "your smtp binding")
    					val success = mailActions.sendMail("your from", "your subject", "your message")
    				} else if (duration < treshold) {
    	} else {
    		logInfo("default.rules", "Stop monitoring Door")
    if (SensorGarageDoor_Duration.state != NULL) {
    	attempt = (SensorGarageDoor_Duration.state as Number).intValue
    } else {
    	attempt = treshold
    if (attempt >= treshold) {
    	logInfo("default.rules", "Request for monitoring Opened Door")
    } else {
    	logInfo("default.rules", "New request for monitoring Opened Door ignored")

    One of the trick is to pass the Lambda Expression as parameter to the Timer (Created with createTimerWithArgument). Indeed, a Timer may not call a “Global” Lambda Expression. To get a Lambda Expression as parameter, this parameter must be defined as Functions$FunctionX (where X is the amount of parameters of the Lambda Expression). In my sample above, my Lambda as one parameter which is itself, to be passed to the Trigger (So, it is typed Functions$Function1).

    You must type explicitly the parameters as Functions$Function1 to be able to use the method “apply()”.


  • Xiamo Aqara and Openhab on Raspberry Pi

    A few notes on using Xiaomi Aqara Sensors and Switches with Openhab 3.

    Click to Read More

    I am using a Zigbee USB key Conbee II from Dresen Eletronik.

    It is plugged into the Raspberry Pi with a USB cable extension to put it away from the other keys used on this RPi, like my Sigma Z-Wave controller.

    I am sing OpenHab 3 (previously OpenHab 2).

    Opposite to the Sigma Z-Wave USB key, there is not mount issue after a reboot due to the usb port id increasing… (See also a solution in French).

    I am using the Phoscon App to connect and manage devices via the Conbee II key. The App is accessible on the http port 80 of the Raspberry.

    To connect a new Xiaomi Aqara device,

    1. “Add a Sensor” or a “Add a Switch” within Phoscon. Pick the type “Other”.
    2. Press the reset button for 5 sec. The blue led should turn on and start blinking after 5 sec. Release the button immediately when it starts blinking. The led will then turn on for 2 or 3 sec and then blink 3 times. It means that the connection is established.
    3. A few second later, the device will appear in Phoscon.

    To get the Things into Openhab, Add the Binding “Dresen Eletronik DeCONZ Binding” and “Scan” for devices.

    I am using with success:

    • Multi Sensors : with values for Temperature, Humidity and Pressure
    • Door and Window Sensors: with Status Opened / Closed
    • A Cube : with events Pushed (various direction), Rotation, Shacked
    • Wireless Mini Switch : One Button Control with 4 events: Single Press, Double Press, Long Press and Long Press Release



    • after a few month using the Door Sensors on my Garage Door, it stopped to send events… The problem was that the captor part was attached on a metal upright which ended to be magnetized by the magnet part moving around…


  • USB ports used by openHab’s Z-Wave Controller change after each reboot on RPI

    Usually, USB keys get assigned a new port such as /dev/ttyACM0, /dev/ttyACM1, etc…, each time they are unplugged and replugged into the RPI or if the RPI reboots. A solution consists in making these ports permanent via symlinks.

    Click to Read More

    This “feature” is a problem as the specified device may not be recognized anymore by configured softwares, like the Z-Wave Binding or openHab.

    See a definitive solution here: make serial USB ports persistent via symlinks.


  • Easily Backup openHab into a Shared Folder

    I am running openHab2 on my raspberry pi 4 using openhabian and I wanted to schedule a backup of my config into a shared folder of my Synology.

    Backup as root

    Openhabian’s backup solution ‘Amanda’ didn’t convince me to automate such a backup. So I wrote my own backup script and scheduled it with a cron job.

    First, create a shared folder named “backups” on your Synology via Control Panel > Shared Folder > Create:

    Next, create a user account named “backup” via Control Panel > User > Create:

    Grant that account write access on the shared folder “backups” via Control Panel > User > backup > Edit > Read/Write

    The Synology part being ready, move now to openhabian, on the RPI, using a ssh console (E.g.: Putty) to create and schedule the backup script. Most parts will have to be done as ‘root’ (to make it simpler… but no safer), so type;

    sudo -i

    If just like me you previously tried to configure the backup with Amanda, using the command “sudo openhabian-config” and then the menu 50 > 52, a mailer daemon (exim4) was probably installed and you want now to remove it… Check if it’s running (not with the command “systemctl –type=service –state=running” but) with:

    sudo service --status-all

    If you see a + in front of exim4, disable and remove it

    sudo systemctl stop exim4
    sudo systemctl disable exim4
    sudo apt-get remove exim4 exim4-base exim4-config exim4-daemon-light
    sudo rm -r /var/log/exim4/

    You can also next uninstall and remove Amanda

    sudo apt remove amanda-client
    sudo apt remove amanda-server
    sudo rm -r /var/lib/amanda/
    sudo rm -r /etc/amanda

    Now, we can start with the preparation of the backup script. Define first a mount point on your RPI. E.g.: “/mnt/backups”:

    mkdir /mnt/backups

    Define next the shared folder of your Synology by editing the fstab file:

    sudo nano /etc/fstab 

    Add the line here under in that file and save your change with CTRL-o, Enter, CTRL-x:

    //<ip of your Synology>/backups /mnt/backups cifs username=backup,password=<password>,uid=1000,gid=1000,vers=3.0 0 0

    Attention: the network is usually not yet available when the fstab file is used to mount the drives a boot time. So this shared folder will most probably not be mounted automatically!

    Create a file:

    nano /home/openhabian/maintenance.sh

    with the backup script here under:

    # Backup Openhab of Synology

    echo $(date) "Run openhab maintenance: $0" >> $log

    if mountpoint -q /mnt/backups
    echo $(date) "Synology's backups share is mounted." >> $log
    echo $(date) "Synology's backups share is not mounted. Try to mount as per fstab definition." >> $log
    sudo mount /mnt/backups
    sleep 3
    if mountpoint -q /mnt/backups
    echo $(date) "Synology's backups share is now successfully mounted." >> $log
    echo $(date) "Synology's backups share cannot be mounted." >> $log

    if mountpoint -q /mnt/backups
    # Keep the 10 last backups
    rm -f $(ls -1t /mnt/backups/Raspberry/openhab2-backup-* | tail -n +11)
    sudo ./runtime/bin/backup /mnt/backups/Raspberry/openhab2-backup-"$(date +"%Y_%m_%d_%I_%M").zip" >> $log
    echo $(date) "custom backups of openhab completed." >> $log
    echo "-----------------------------------------------------------------" >> $log

    Make that script executable (for all users…)

    sudo chmod a+x maintenance.sh

    To run that script as root on a regular basis, you have to schedule it as root (using now sudo explicitly if you didn’t type sudo -i earlier) via crontab:

    sudo crontab -e

    If it’s the first time you run crontab, you will have to pick your prefered editor. I advice nano 😉

    Select an editor. To change later, run 'select-editor'.
    1. /bin/nano <---- easiest
    2. /usr/bin/vim.basic
    3. /usr/bin/mcedit
    4. /usr/bin/vim.tiny
    5. /bin/ed

    Choose 1-5 [1]: 1

    In crontab, add this at the end and ave that change with CTRL-o, Enter, CTRL-x:

    0 1 * * * /home/openhabian/maintenance.sh

    Notice: if you want to mount the shared drives at boot, which usually fails as mentioned previously as the network is not yet available when fstab is first called, you can add this in the crontab too:

    @reboot sleep 300; mount -a

    You can now try the script with:

    sh /home/openhabian/maintenance.sh

    If it works, it should also work when triggered by the cron job.

    Backup as openhabian

    To run scripts as root is usually not recommended. But the backup script of openhab may only be run as root… We could run it with the account ‘openhab’, but the backup files will belongs to the user ‘openhabian’, making the cleanup tricky. I you really don’t want to run and schedule my script as root, then the best option is to run it with the account “openhabian”:

    Still being is root mode (sudo -i), create the log file manually and grant access for all users:

    touch /var/log/maintenance.log
    chmod a+rw /var/log/maintenance.log


    Authorize the user “openhabian” to execute the backup script “/usr/share/openhab2/runtime/bin/backup”. To do this, you have to create a file in the /etc/sudoers.d folder. All files in that folder are used by the “sudo” command to authorize configured users to execute specified commands as root, with or without password. You MUST ABSOLUTELY edit that file with the command “visudo“. This one will check that your changes are valid. If you edit that file with another editor and it contains an error, you won’t be able to use the “sudo” command anymore (you will have to plug the SD card into a USB adapter on another raspberry to fix the issue or to simply delete the invalid file. USB device are automatically mounted under /media/usbxxx if you installed the package usbmount).

    visudo /etc/sudoers.d/openhab

    In that file, add the line here under and save your change with CTRL-o, enter, CTRL-x

    # Allow openhabian user to execute the backup script
    openhabian ALL=(ALL) NOPASSWD: /bin/mount, /usr/share/openhab2/runtime/bin/backup


    Unschedule the script from root’s crontab (remove the line added with crontab -e)

    crontab -e
    0 1 * * * /home/openhabian/maintenance.sh


    And schedule it now within openhab’s crontab (has to be done as ‘openhabian’  user)

    sudo -u openhabian crontab -e

    And add

    0 1 * * * /home/openhabian/maintenance.sh


    Et voilà.


    PS.: If you experience issues when mounting the remote shared folder, try to mount it interactively (using an administration account of  your Synology or an account having a password without symbols such as %, # or !)

    apt install smbclient 
    smbclient //<remote ip>/<shared folder> -U <user account>

    You can also check the latest messages from the kernel

    dmesg | tail -n10


  • Install Java 8 SDK and OpenHab 2 on Raspberry Pi Desktop for RPI 4

    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="10 (buster)"

    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:
    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 


    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/
    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
    only guest=no
    create mask=0777
    directory mask=0777

    [openHAB2-conf]comment=openHAB2 site configuration
    only guest=no
    create mask=0777
    directory mask=0777

    [openHAB2-logs]comment=openHAB2 logs
    only guest=no
    create mask=0777
    directory mask=0777

    [openHAB2-backups]comment=oepnHAB2 backups
    only guest=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à!


  • Use a Z-Wave Controller USB Key with openHAB in Docker on a RPI 4

    It took me quite some hours to be able to use my Aeotec Z-Stick Gen5 (ZW090) key within my Docker image of openHAB, running on a Raspberry Pi 4 (with a Raspberry Pi OS). Here are all the tips I used.

    Click to Read More

    First, before plugging the controller  in your RPI, configure it to see the Serial Ports. Connect onto your RPI within a SSH Console (ex.: via Putty)  and type the command:

    sudo raspi-config

    Use “5 interfacing Options” > “P6 Serial” > “Yes” > “Ok”

    And now reboot.

    Next, back into a SSH conscole, check what USB devices already exists with the command:


    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

    And flush the kernel and boot logs:

    sudo dmesg -c >> ~/dmesg-`date +%d%m%Y`.log

    Then, plug your Z-Wave Controller USB Key in a USB Port and check that it’s detected and mounted properly:


    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 009: ID 0658:0200 Sigma Designs, Inc. Aeotec Z-Stick Gen5 (ZW090) - UZB
    Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


    [ 3124.779069] usb 1-1.4: new full-speed USB device number 9 using xhci_hcd
    [ 3124.919928] usb 1-1.4: New USB device found, idVendor=0658, idProduct=0200, bcdDevice= 0.00
    [ 3124.919942] usb 1-1.4: New USB device strings: Mfr=0, Product=0, SerialNumber=1
    [ 3124.919953] usb 1-1.4: SerialNumber: 32303136-3131-3033-3030-303031383932
    [ 3124.926704] cdc_acm 1-1.4:1.0: ttyACM0: USB ACM device


    “lsusb” should show you a new device. Ex.: Aeotec Z-Stick Gen5 (ZW090) – UZB.

    And “dmesg” must should you the mount point: cdc_acm 1-1.4:1.0: ttyACM0: USB ACM device.

    If you don’t see the mount point, then you possibly have a device not supported by the RPI 4. It seems that it is the case with the old Aeotec “Z-Stick Gen5”. “New Z-Stick Gen5” and “Z-Stick Gen5+” should however be compatible. But there is a trick: plug your key on the RPI 4 via a USB HUB (2.0 or 3.0).

    I presume that the Docker Image is already up and running. If not, install it.

    sudo useradd -r -s /sbin/nologin openhab
    usermod -a -G openhab pi
    mkdir /opt/openhab
    mkdir /opt/openhab/conf
    mkdir /opt/openhab/userdata
    mkdir /opt/openhab/addons
    chown -R openhab:openhab /opt/openhab

    Check the id of the user openhab with:

    id openhab

    uid=999(openhab) gid=994(openhab) groups=994(openhab)

    Grant access on the Serial Port for the user ‘openhab’:

    sudo chmod 777 /dev/ttyACM0
    sudo chown openhab /dev/ttyACM0

    And use the uid and gid found above in the following command, setting the ttyA* found previously and specifying the version to be used:

    docker run –name openhab –net=host –device=/dev/ttyACM0 -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -v /opt/openhab/conf:/openhab/conf -v /opt/openhab/userdata:/openhab/userdata -v /opt/openhab/addons:/openhab/addons -d -e USER_ID=<uid> -e GROUP_ID=<gid> –restart=always openhab/openhab:latest


    Now, using Portainer (because it’s easy), open a console within openhab… Portainer is not yet installed ? Do it with:

    docker run -d -p 9000:9000 -p 8000:8000 –name portainer1 –restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer:/data portainer/portainer:latest

    Go to the page http://<Your RPI IP>:9000, open the Containers and click on the “Exec Console” icon of ‘openhab’ container:

    Grant the same accesses inside the image than on the RPI:

    sudo chmod 777 /dev/ttyACM0
    sudo chown openhab /dev/ttyACM0

    chown -R openhab:openhab /opt/openhab

    Now restart the ‘openhab’ container (with the icon Restart 😉 ). It will take some minutes to be available. But once you can get into it, go to the Things and configure the Controller to use the Serial Port ttyACM0:


    Et voilà


  • OpenHab: ServiceLocatorImpl has been shut down

    I found a weird error by accident in the openhab.log of my Synology. It was due to the “Localisation” not configured properly in openHab’s System.

    Click to Read More

    I found that error after stopping and starting manually openHab from a SSH console opened on my Synology to solve another issue.

    To stop openHab installed on a Synology as explained here, via a SSH console run as root (as explained here), execute:

    • cd /var/packages/openHAB/target
    • ./runtime/bin/stop

    To restart openHab later execute:

    • ./runtime/bin/start

    NB.: if you execute this command soon after the stop, it won’t work. You can simply re-execute the command a second time.

    Here are more details about the error that I found in the log (located into \\<YourNas>\SmartHome\openHAB\userdata\logs\openhab.log)

    javax.servlet.ServletException: javax.servlet.ServletException: A MultiException has 1 exceptions. They are:
    1. java.lang.IllegalStateException: ServiceLocatorImpl(__HK2_Generated_2,3,718060201) has been shut down

    at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:88) ~[bundleFile:?]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.20.v20190813]
    at org.eclipse.jetty.server.Server.handle(Server.java:494) ~[bundleFile:9.4.20.v20190813]
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [bundleFile:9.4.20.v20190813]
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [bundleFile:9.4.20.v20190813]
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.20.v20190813]
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [bundleFile:9.4.20.v20190813]
    at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [bundleFile:9.4.20.v20190813]
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) [bundleFile:9.4.20.v20190813]
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) [bundleFile:9.4.20.v20190813]
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) [bundleFile:9.4.20.v20190813]
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) [bundleFile:9.4.20.v20190813]
    at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367) [bundleFile:9.4.20.v20190813]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [bundleFile:9.4.20.v20190813]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [bundleFile:9.4.20.v20190813]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]

    This error appears because the location is not set in OpenHAB and your browser probably didn’t have the permission to pass its own location to openhab.

    The issue can be resolved by manually via the PaperUI > Configuration > System > Regional Settings.  There, define your language, your country/region, your Time Zone and your location (with a latitude and longitude – or – by moving the openHab pin onto your location).