Packaging Domoticz for Debian, Ubuntu, Raspbian and Fedora

Today I published fresh packages for Domoticz and the Domoticz-Zigate. As the instructions have changed for setting up the Domoticz-Zigate, this is an updated blog, verified with v4.12.102 of the Domoticz-Zigate plugin.

Getting started in home automation has never been easier, cheaper and more important

Many countries are now talking about longer lockdowns to restrict new strains of the Coronavirus. When the new US President takes office, many suspect he will introduce more stringent restrictions than his predecessor. Smart lighting can make life more enjoyable when spending time at home.

At the same time, more and more companies are bringing out low-cost Zigbee solutions. A previous blog covered Lidl's new products in December. Ikea's products are also incredibly cheap, they include a wide range of bulbs, buttons, motion sensors, smart sockets and other accessories that work with free solutions like Domoticz.

NOTE: when you use the ZiGate stick, you do not need to buy the hub from Philips, Ikea or any other vendor and you do not need their proprietary apps. Your ZiGate stick becomes the hub.

Packaging details

Federico Ceratto and I have been working on the Debian packaging of Domoticz, one of the leading free and open source home automation / smart home solutions. As there are a large suite of packages involved, I'm keen to find more people willing to collaborate on a parallel packaging for Fedora. Many of the enhancements we've made for Debian, such as the directory structure, are applicable across all GNU/Linux distributions.

As part of that effort, I've also been packaging the plugin for the Zigate USB stick and two of the utilities for updating firmware on the Zigate, the JennicModuleProgrammer and the zigate-flasher. This gives users a complete solution in the form of familiar packages.

These are initially Debian packages, also available for Raspbian, but I also try to share any lessons from this effort with the upstream developers and also provide a foundation for Fedora packaging. Fedora already has the core Domoticz package since Fedora 32. Some of the other related packages described here are fairly straightforward to port.

Raspberry Pi 2.0 with Zigate USB stick

Trying the packages

Raspbian setup (Raspbian users only)

If you have a regular Debian setup, you can skip to the next section.

  1. Download the Raspbian light image from the official Raspbian download page
  2. Write the image to an SD card using
    or a similar tool
  3. Boot the Raspberry Pi
  4. Login as user pi with the password raspberry
  5. Run
    sudo raspi-config
  6. Set a password for the pi user, the default is raspberry
  7. Set the hostname
  8. In (4) Localization settings, set your Locale, Timezone and Keyboard
  9. In (5) Interfacing, enable SSH
  10. At the command line, run
    to verify the time and time synchronization is correct
  11. Run
    ip addr
    to see your IP address
  12. (optional) Connect to the Pi from your usual workstation and copy your SSH public key to
  13. (optional) Disable PasswordAuthentication in
    (you don't want the script kiddies next door turning on your heating system in the middle of summer do you?)

Package repository setup (Debian, Raspbian and Ubuntu users)

As these were not included in the recent release of Debian 10 (buster) and as they are evolving more rapidly than packages in the stable distribution, I'm distributing them through Debify.

To use packages from Debify, the first step is to update your apt configuration. This works for regular Debian or Raspbian systems running stretch or buster:

$ wget -O - | bash

Package installation

$ sudo apt update
$ sudo apt install domoticz-zigate-plugin

All the necessary packages should be installed automatically. A sample installation log is below for comparison.

Zigate users - check firmware version

You may want to check that you have the latest firmware installed in your Zigate.

  1. Download the firmware image from here
  2. If your apt setup automatically installs Recommended packages then jennic-module-programmer has already been installed for you. If not, you can do
    sudo apt install jennic-module-programmer zigate-flasher
    . You can also try the alternative tool, zigate-flasher
  3. Unplug your Zigate USB stick and open the case. Hold down the button and while holding the button, reconnect it to the USB port. The blue light should now be illuminated but very dimly. This means it is ready for a firmware update.
  4. Run the update, for example, if you copied or downloaded the firmware to /tmp and if you have no other USB serial device attached, you could use the following command:
    sudo JennicModuleProgrammer -s /dev/ttyUSB0 -f /tmp/ZiGate_v3.1d.bin
  5. Wait for the command to complete successfully
  6. Detach the Zigate and put it back into its case
  7. Attach the Zigate again
  8. Restart Domoticz:
    sudo systemctl restart domoticz

If the JennicModuleProgrammer utility doesn't work for you, if it sits there for ten minutes without doing anything you can also try the zigate-flasher. I packaged both of these so you have the choice: please share your feedback in the Domoticz forums. Repeat the steps above, replacing step 4 with:

  1. $ sudo zigate-flasher -p /dev/ttyUSB0 -w /tmp/ZiGate_v3.1d.bin
    Found MAC-address: 00:11:22:33:44:55:66:77
    writing new flash from /tmp/ZiGate_v3.1d.bin

Zigate users: quick Domoticz setup

Native Zigbee bindings between the light switches (dimmers) and the bulbs

Zigbee devices can link directly to each other. This ensures that they keep working if the hub / ZiGate is offline.

To do this with Domoticz and/or multiple bulbs, you need to make the connections in a specific order:

  1. For best results, make sure every other device is disconnected from power and only try to join one device at a time. Otherwise, the wrong device may become associated with a switch/button.
  2. Reset each bulb, one at a time, and then join them in Domoticz using the procedure described in the previous section
  3. Reset each light switch/dimmer, one at a time and then join them in Domoticz using the procedure described in the previous section. To reset a Philips Hue dimmer, press the setup button on the back. To reset and Ikea dimmer, press the button on the back 4 times in 5 seconds.
  4. Unplug all the light bulbs, smart sockets and other devices except for the one you want to join first
  5. Hold the light switch/dimmer close to the bulb and complete the native joining procedure, for example, if it is an Ikea dimmer, you hold the button on the back for 10 seconds.
  6. Unplug the bulb, plug in the next bulb and repeat the procedure.
  7. Note that you can join more than one bulb to the same light switch/dimmer in this procedure and you can also join more than one light switch to the same bulb.
  8. You will be able to control these bulbs from Domoticz but if your Domoticz is offline, you can also control them directly with the light switches/dimmers paired in this procedure.

Next steps and troubleshooting

Please share your feedback and questions through the Domoticz forums.

Sample installation log

pi@pi5:~ $ sudo apt install domoticz-zigate-plugin
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  domoticz jennic-module-programmer libopenzwave1.6 libpython3-dev libpython3.5-dev openzwave
The following NEW packages will be installed:
  domoticz domoticz-zigate-plugin jennic-module-programmer libopenzwave1.6 libpython3-dev libpython3.5-dev openzwave
0 upgraded, 7 newly installed, 0 to remove and 74 not upgraded.
Need to get 51.7 MB of archives.
After this operation, 91.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 debify-raspbian-stretch-backports/main armhf libopenzwave1.6 armhf 1.6+ds-1~bpo9+1 [406 kB]
Get:2 stretch/main armhf libpython3.5-dev armhf 3.5.3-1+deb9u1 [36.9 MB]
Get:3 debify-raspbian-stretch-backports/main armhf openzwave armhf 1.6+ds-1~bpo9+1 [24.6 kB]
Get:4 debify-raspbian-stretch-backports/main armhf domoticz armhf 4.11020-2~bpo9+1 [10.8 MB]
Get:5 debify-raspbian-stretch-backports/main armhf domoticz-zigate-plugin all 4.4.9~beta1-2~bpo9+1 [3,515 kB]
Get:6 debify-raspbian-stretch-backports/main armhf jennic-module-programmer armhf 0.6-1~bpo9+1 [9,690 B]
Get:7 stretch/main armhf libpython3-dev armhf 3.5.3-1 [18.7 kB]                                                                     
Fetched 51.7 MB in 9s (5,717 kB/s)                                                                                                                                           
Selecting previously unselected package libopenzwave1.6.
(Reading database ... 34831 files and directories currently installed.)
Preparing to unpack .../0-libopenzwave1.6_1.6+ds-1~bpo9+1_armhf.deb ...
Unpacking libopenzwave1.6 (1.6+ds-1~bpo9+1) ...
Selecting previously unselected package libpython3.5-dev:armhf.
Preparing to unpack .../1-libpython3.5-dev_3.5.3-1+deb9u1_armhf.deb ...
Unpacking libpython3.5-dev:armhf (3.5.3-1+deb9u1) ...
Selecting previously unselected package libpython3-dev:armhf.
Preparing to unpack .../2-libpython3-dev_3.5.3-1_armhf.deb ...
Unpacking libpython3-dev:armhf (3.5.3-1) ...
Selecting previously unselected package openzwave.
Preparing to unpack .../3-openzwave_1.6+ds-1~bpo9+1_armhf.deb ...
Unpacking openzwave (1.6+ds-1~bpo9+1) ...
Selecting previously unselected package domoticz.
Preparing to unpack .../4-domoticz_4.11020-2~bpo9+1_armhf.deb ...
Unpacking domoticz (4.11020-2~bpo9+1) ...
Selecting previously unselected package domoticz-zigate-plugin.
Preparing to unpack .../5-domoticz-zigate-plugin_4.4.9~beta1-2~bpo9+1_all.deb ...
Unpacking domoticz-zigate-plugin (4.4.9~beta1-2~bpo9+1) ...
Selecting previously unselected package jennic-module-programmer.
Preparing to unpack .../6-jennic-module-programmer_0.6-1~bpo9+1_armhf.deb ...
Unpacking jennic-module-programmer (0.6-1~bpo9+1) ...
Setting up jennic-module-programmer (0.6-1~bpo9+1) ...
Setting up libopenzwave1.6 (1.6+ds-1~bpo9+1) ...
Setting up libpython3.5-dev:armhf (3.5.3-1+deb9u1) ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
Processing triggers for man-db ( ...
Setting up libpython3-dev:armhf (3.5.3-1) ...
Setting up openzwave (1.6+ds-1~bpo9+1) ...
Setting up domoticz (4.11020-2~bpo9+1) ...
Created symlink /etc/systemd/system/ → /lib/systemd/system/domoticz.service.
Setting up domoticz-zigate-plugin (4.4.9~beta1-2~bpo9+1) ...
Adding user `domoticz' to group `dialout' ...
Adding user domoticz to group dialout
pi@pi5:~ $