Synology

From Domoticz
Jump to navigation Jump to search

Domoticz runs very well on a Synology NAS. In case your Synology supports Docker, installation is quite easy.

Dockerized Domoticz

Requirements:

  • USB drivers for Synology from Jadahl( backup) (currently 7.0 and some 7.1 are supported); also you need SSH access to your Synology
  • A Synology with Docker support

The described method is inspired on a discussion which can be found here. For more information about Domoticz Docker check this wiki or docker hub

Steps:

  1. Use the Synology Package Manager to install Docker (below 7.2) or Container manager (> 7.2)
  2. Open Docker, go to the Registry tab and download the Domoticz image labeled 'domoticz/domoticz:beta' for latest beta or 'domoticz/domoticz:stable' for latest stable.
  3. Switch to the Image tab and launch Domoticz with the following settings:
    • Container name: Domoticz
    • Execute container using high privilege (to access devices like /dev/ttyACM0 or /dev/ttyUSB0)
    • Advanced settings:
      • Advanced settings: Enable auto-restart
      • Volume: Add Folder:
        • Create Folder 'domoticz', select this folder
        • Mount path: /opt/domoticz/userdata
      • Port settings:
        • Local port 7080, container port 80
      • Environment:
        • WWW_PORT: 80
        • SSL_PORT: 0
        • LOG_PATH: /opt/domoticz/userdata/domoticz.log (only for debugging)

This configuration lets Domoticz to be served at port 7080, which is fine if you add a reverse proxy. You may choose any port, even 80, if you like.

Python libraries

The Domoticz image currently comes with a limited set of Python libraries. In case you need more, open Docker on your Synology, go to the Domoticz container, select Details, Terminal, and open 'bash'. Depending on the libraries you run something like:

        pip3 install tzlocal
        pip3 install pytz

It is also possible to use a custom startup script to add these Python modules (and other extra's) in the container at startup, see Docker#custom startup script for the container

USB drivers

Unfortunately, Synology DSM doesn't come with USB drivers. If Domoticz needs access to certain USB devices, install these drivers from Jadahl (backup). You need to figure out which DSM and hardware version you own. In case of DSM 7.0 on a Gemini Lake CPU, open an SSH terminal to your Synology and install the drivers as follows:

        URL=http://www.jadahl.com/iperf-arp-scan/DSM_7.0/geminilake
        for module in ch341 cp210x pl2303 ti_usb_3410_5052; do
          if [ -f /lib/modules/$module.ko ]; then
            echo Module $module already exists
          else
            sudo wget $URL/$module.ko -O /lib/modules/$module.ko
          fi
        done
        
        sudo tee /usr/local/etc/rc.d/start-usb-drivers.sh <<'HERE'
        #!/bin/sh
        case $1 in
          start)
            insmod /lib/modules/usbserial.ko > /dev/null 2>&1
            insmod /lib/modules/cdc-acm.ko > /dev/null 2>&1
            insmod /lib/modules/cp210x.ko > /dev/null 2>&1
        #   insmod /lib/modules/ch341.ko > /dev/null 2>&1
        #   insmod /lib/modules/pl2303.ko > /dev/null 2>&1
        #   insmod /lib/modules/ti_usb_3410_5052.ko > /dev/null 2>&1
        #   insmod /lib/modules/ftdi_sio.ko > /dev/null 2>&1
            ;;
          stop)
            exit 0
            ;;
          *)
            exit 1
            ;;
        esac
        HERE
        chmod a+x /usr/local/etc/rc.d/start-usb-drivers.sh

External access

In case you want to expose Domoticz to the outside world, you need to configure a so called reverse proxy with SSL enabled. On DSM 7.0 open Settings and go to the Login Portal. Open the Advanced tab and click on Reverse Proxy, click Create, and configure it like:

  • Reverse Proxy Name: Domoticz
  • Source:
    • Protocol: HTTPS
    • Hostname: the hostname your Domoticz should be accessible to
    • Port: 443
    • Enable HSTS: checked
  • Destination:
    • Protocol: HTTP
    • Hostname: localhost
    • Port: 7080
  • Custom header:
    • Upgrade: $http_upgrade
    • Connection: $connection_upgrade

You probably want to add an DDNS entry in the External Access section of your DSM configuration. And add a LetsEncrypt certificate to the Security entry of the DSM configuration, tab Certificate.