From Domoticz
Jump to: navigation, search

This page describes how to compile/build the latest beta snapshot of Domoticz for Debian-based Linux operating systems. There's no need for all this if you're just installing a pre-built binary (see the downloads page for that).

Compiling the source code

The procedure is the same as for the Raspberry Pi/Debian systems. (Yes we need to change the topic here...)
Follow the steps provided here: Raspberry_Pi_-_Build_Domoticz_from_source

Allow non-root user to access ttyUSB* ports

If you don't plan on interfacing Domoticz with USB and/or serial devices, you can skip this step.

By default (at least on Ubuntu) a non-root user has no permission to access the ttyUSB* ports. So if you have Domoticz running under a separate user (which is always a good idea to make the system more secure), Domoticz isn't allowed access to your RFXCOM for example. Here are two methods of doing it. For most people the first one by adding the user to the dialout goup is enough and by far the easiest.

Adding the user to the dialout group

This can be done by running the command below:

sudo usermod -a -G dialout YOURUSERNAME

(Where you replace YOURUSERNAME with the user that runs Domoticz.)

Setting up a udev rule

Alternatively you can setup (as root) a udev rule that matches the RFXCOM device. To find which attributes match your device use the command:

udevadm info -a -p $(udevadm info -q path /dev/ttyUSB1) | less

Where /dev/ttyUSB1 is the device. If you wish to run Domoticz under the YOURUSERNAME credentials, who is member of the YOURGROUPNAME group and your device has serial YOURSERIAL a suitable udev rule would be:


Save it to a file under /etc/udev/rules.d/ with the .rules extention and run:

service udev reload

Unplug and replug the device and execute:

ls -l /dev/ttyUSB*

You should see something like

crw-rw---- 1 domoticz domoticz 188, 1 Nov 10 15:27 /dev/ttyUSB1
lrwxrwxrwx 1 root     root          7 Nov 10 15:27 /dev/ttyUSB21 -> ttyUSB1

The added SYMLINK+= creates an additional link to the device node. This is a static name that is useful when you have multiple usb-serial devices that go into your box. Use the static link in Domoticz. For more information on udev rules have a look here:

Starting Domoticz automatically when the system boots

There are basically two ways to do this - via init.d (which starts things serially) or via systemd (which starts things up in parallel and therefore leads to faster booting). On modern systems the systemd method is generally preferred.

Option 1: Init.d Method

To let Domoticz start automatically when the system boots (which is probably the case, as most people run it on a headless server), run the commands below, (You want to end up in /home/YOURUSERNAME/domoticz/)

cd domoticz
sudo cp /etc/init.d
sudo chmod +x /etc/init.d/
sudo update-rc.d defaults

Edit the startup script.

sudo nano /etc/init.d/

The lines you usually need to change are USERNAME, DAEMON and DAEMON_ARGS

DAEMON_ARGS="-daemon -www 8080"
  • Change the USERNAME variable to the user you want domoticz to be run as. It's recommended to run domoticz as its own user and not as root, due to security reasons.
  • If you installed Domoticz in the USERNAME home directory /home/yourusername/domoticz you don't need to change the DAEMON variable. If you installed it in an alternate location for example /usr/local/domoticz/ you should change DAEMON to /usr/local/domoticz/$NAME
  • If you want to use another web interface port change the '8080' in: DAEMON_ARGS="-daemon www 8080" to your own port.

Note: To be able to use ports below 1024, for example the standard port for webbrowsing, 80, you need to run domoticz as the root user.

If you want to see more arguments for DAEMON_ARGS run this in the domoticz directory. This is usually not needed.

./domoticz -h

Domoticz will now start automatically when you reboot your machine.

Manually controlling the Domoticz service

This only works if you followed the above steps.

You can now start/stop/restart and check the status of domoticz with:

sudo /etc/init.d/ start
sudo /etc/init.d/ stop
sudo /etc/init.d/ restart
sudo /etc/init.d/ status

If your system supports it you can instead use:

sudo service start
sudo service stop
sudo service restart
sudo service status

Option 2: Systemd Alternative (Preferred)

Open the systemd configuration file :

vi /etc/systemd/system/domoticz.service
       ExecStart=/home/domoticz/domoticz/domoticz -www 8080 -sslwww 443
       # Give the right to open priviliged ports. This allows you to run on a port <1024 without root permissions (user/group setting above)
       # The next line was previously working, so try this on older systems.
       # ExecStartPre=setcap 'cap_net_bind_service=+ep' /home/domoticz/domoticz/domoticz
       # The below works on ubuntu 16 LTS.

or on Raspberry Pi Stretch as root (remove '#' on User and Group lines to run as 'Pi' user):

      ExecStart=/home/pi/domoticz/domoticz -www 8080 -sslwww 443
      ExecStartPre=setcap 'cap_net_bind_service=+ep' /home/pi/domoticz/domoticz

Enable the service

systemctl daemon-reload
systemctl enable domoticz.service

Start the service

systemctl start domoticz.service

Note: Use only one of these two alternatives (init.d method or systemd method) for auto-start.

Updating Domoticz

Once in a while, a new Domoticz version is released, and of course you want to update. You can do this with the commands below:

  1. Navigate to the directory where Domoticz is installed: cd domoticz (You want to end up in /home/YOURUSERNAME/domoticz/)
  2. Update to the latest Beta with: ./updatebeta
  3. Update to the latest Release with: ./updaterelease

If all went correctly, Domoticz should be updated to the latest version and should be running again automatically.

Attention: when you use Monit, be sure to disable it before doing the update process, otherwise after you have stopped Domoticz by hand yourself, it will get restarted automatically by Monit within a few minutes (because that is what is Monit should do normally).
Stopping Monit can be done by sudo /etc/init.d/monit stop and after updating it can be started again with sudo /etc/init.d/monit start.
You could also use this command: make && sudo /etc/init.d/ start && sudo /etc/init.d/monit start to update, start Domoticz & start Monit when updating is done.

Script to update almost automatically

For updating almost automatically, i made this script

#! /bin/sh
cd /home/YOURUSERNAME/domoticz/ \
&& sudo /etc/init.d/monit stop \
&& sudo /etc/init.d/ stop \
&& git pull \
&& make \
&& sudo /etc/init.d/ start\
&& sudo /etc/init.d/monit start

Save it as, give it executable rights (chmod +x and call it by sh /home/YOURUSERNAME/
It will change the current path to the Domoticz folder, stop Monit, stop Domoticz, pull binaries, compile, start Domoticz, start Monit again.
Very handy to run & go do something else.

In theory it can work automatically (weekly cronjob for example), however when running as a non-root user (which is the case in my situation), it will ask for the password of the user. But after you have provided the password (almost immediately after the script has started), it will continue without needing any further user input.
In theory it is possible to let it run fully automated, but i myself prefer a bit of feedback (watching afterwards if all went well). If you want to work around this sudo password asking, look here.

when compiling the main Domoticz binary. For more information read this thread on the forum: Link

Problems locating Python

Some users, particularly those on old operating systems see the following message when starting Domoticz:

 2016-12-20 09:44:32.251 Failed dynamic library load, install the latest libpython3.x library that is available for your platform. 

this shows that, even though python3 may be on the system, the python library can not be located. This error will not stop Domoticz from starting but will mean that hardware supported by the Python Plugin Framework will not be available. To fix this, install the newest version of libpython3 for the platform. For example, RaspberryPi Jessie has python 3.4 on it but the library is not included. Executing:

 sudo apt-get install libpython3.4

should solve the issue. Note that python 3.4 is the earliest support version of python, where available later versions should always be used.
If you are building from source and python 3 is installed but Make is not able to progress, try to add


just before find_package(PythonLibs 3.4) in the CMakeLists.txt

If your platform does not have a compatible version, for example RaspberryPi Wheezy, then one can be built from source using:

 tar -xvf Python-3.5.2.tar.xz
 cd Python-3.5.2
 ./configure --enable-shared
 sudo make install

Don't miss the enabled-shared flag otherwise libpython will not be built.

Note: Only peform this step if you are building from source and are having issues, it should not be required.
After building Python 3.5.x change CMakeLists.txt

 option(USE_PYTHON_PLUGINS "Use Python Plugins" YES)
   set(Python_ADDITIONAL_VERSIONS 3.5)      <---- add this line
   find_package(PythonLibs 3.5)   <---- change version into 3.5

Add support for Tellstick

If you need support for Tellstick or Tellstic Duo you need to install telldus-core before compiling Domoticz. On Debian-based systems (For example Ubuntu and Raspbian) telldus-core can be installed by doing the following:

echo "deb stable main" | sudo tee /etc/apt/sources.list.d/telldus.list
wget -q -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install libtelldus-core-dev