Synology

From Domoticz
Jump to: navigation, search

There are two ways to get Domoticz running on your Synology: the easy way and the hard way.

The easy way: install a ready-made package

The simplest way to get Domoticz on your Synology NAS is to manually install a ready-made package for Synology. Thanks to the great effort of 'Jumbotroll', installing Domoticz takes just a couple of clicks:

1. Download a package from his website that corresponds with your Synology type.
2. Log in to your Synology, open the package manager, and choose 'manual install'. Simply select the package you downloaded earlier.
3. Done!

These packages already come pre-packed with other drivers you may need in case you want to plug in other sensors and wireless transmitters like RFLink into your Synology.

More details can be found in this forum thread.

The hard way: installing and compiling Domoticz yourself

If you always want the newest Domoticz version and/or want to edit things in the package, follow the steps below.

This tutorial is written against DSM 5.1 (5021) and tested on a DS212+

Updated patches for:
- Domoticz 2179
- OpenZWave 965

Bootstrap your Synology

For this to work, please make sure your NAS is bootstrapped.
Follow the guide below, start with the section: How to install ipkg:
http://www.b.shuttle.de/hayek/mediawiki/w/index.php?title=Overview_on_modifying_the_Synology_Server,_bootstrap,_ipkg_etc

NOTE: If you want to know your processor architecture and you are already on DSM6+ go to Control Panel > Info Center and notice the processor architecture there.

Example for DS212+ (so this might be different per hardware architecture)
cd /volume1/@tmp
wget http://web.archive.org/web/20121005035819/http://wizjos.endofinternet.net/synology/archief/syno-mvkw-bootstrap_1.2-7_arm-ds111.xsh
chmod +x syno-mvkw-bootstrap_1.2-7_arm-ds111.xsh
./syno-mvkw-bootstrap_1.2-7_arm-ds111.xsh

If you can not issue the command ipkg update then pay attention to Step 8 in the above tutorial, this also applies for DSM 5

Installing packages

login with user 'root' and perform the following commands

ipkg update
ipkg upgrade
ipkg install gcc
ipkg install make
ipkg install optware-devel (dont worry about the wget-ssl error)
ipkg install boost-dev boost-thread boost-system boost-date-time boost-python
ipkg install libcurl-dev
ipkg install libusb
ipkg install git

cp /opt/lib/libboost_* /lib

Install CMake

To make live easier we are going to use the binary distribution of CMake
Please check at the below webpage for the correct download file:

http://www.cmake.org/cmake/resources/software.html

The below example if for Linux i386 based systems like a DS212+

go to your home folder, for instance if your username is rob issue:
cd /volume1/homes/rob

wget http://www.cmake.org/files/v3.1/cmake-3.1.0-Linux-i386.sh
chmod +x cmake-3.1.0-Linux-i386.sh
./cmake-3.1.0-Linux-i386.sh

(press space, accept the license, and for install location, answer yes to all questions

rm cmake-2.8.12.2-Linux-i386.sh

Install open-zwave

In order to use open-zwave you will need to compile this first.
If you are certain you will never user open-zwave, then you can skip this section

still in your home folder (/volume1/home/rob), issue the following commands

svn co http://open-zwave.googlecode.com/svn/trunk/ open-zwave-read-only
cd open-zwave-read-only
wget http://www.domoticz.com/patches/domoticz_synology_openzwave.patch
patch -p0 -i domoticz_synology_openzwave.patch
make
cd ..

Install Domoticz

still in your home folder (/volume1/home/rob), issue the following commands

git clone https://github.com/domoticz/domoticz.git domoticz
cd domoticz

wget http://www.domoticz.com/patches/domoticz_synology_domoticz.patch
patch -p0 -i domoticz_synology_domoticz.patch

cmake CMakeLists.txt
make

Possible compile error at the last step

If you encounter a compile error at the last step like:

Linking CXX executable domoticz
/opt/arm-none-linux-gnueabi/lib/libdl.so.2: undefined reference to `[email protected]_PRIVATE'
collect2: ld returned 1 exit status
make[2]: *** [domoticz] Error 1
make[1]: *** [CMakeFiles/domoticz.dir/all] Error 2
make: *** [all] Error 2


Then issue the following command:

mv /opt/arm-none-linux-gnueabi/lib/libdl.so.2 /tmp
make

You should now see:
Linking CXX executable domoticz
[100%] Built target domoticz


Now you should have the binary application, you can start it with
./domoticz

Updating Domoticz

To update Domoticz in a later stage to a future version issue:
cd domoticz
git pull
wget http://www.domoticz.com/patches/domoticz_synology_domoticz.patch
patch -p0 -i domoticz_synology_domoticz.patch
make

Installing FTDI drivers

In order to work with most USB devices like the RFXCom RFXtrx433 you might need to install additional FTDI drivers to get this working.

Install the FTDI and usb drivers. For a tutorial on a DS212+ see:
http://sirloon.net/installing-usb-serial-modules-on-nas-synology-ds212

basic installation:
download the two files below and issue:

insmod usbserial.ko
insmod ftdi_sio.ko

mknod /dev/usb/ttyUSB0 c 188 0

Plugin your RFXtrx transceiver, and verify the USB device is found with:
dmesg

You should see it found the device and assigned a usb device (in my case ttyUSB0, and it gets linked to /dev/usb/ttyUSB0)

now restart Domoticz

Giving Domoticz user permissions to use ttyUSB0

It could happen that the Domoticz install went fine, but you still can't control switches with the RFXCOM. This could be due to the fact that the Synology user under which your Domoticz install doesn't have the correct rights to access ttyUSB0
This can be fixed by adding the user to the 'dialout' group.
Web search how to do this ('synology serial dialout'), or have a look at this tutorial(provide your own user instead of the provided 'openremote').

Automatic Startup

remember if your user is 'rob' domoticz is installed in:
/volume1/homes/rob/domoticz/

The startup script domoticz.sh found in the installation needs to be copied:

cp /volume1/homes/rob/domoticz/domoticz.sh /opt/etc/init.d/S99domoticz.sh

vi /opt/etc/init.d/S99domoticz.sh

change:

DAEMON=/home/pi/domoticz/domoticz

to

DAEMON=/volume1/homes/rob/domoticz/domoticz


chmod +x /opt/etc/init.d/S99domoticz.sh

Domoticz should now start after a reboot


Nefit easy on synology with DSM 6.0.2

Tutorial
Nefit easy on synology with DSM 6.0.2
Install node.js v4.2.6-0158 using package center from publisher Synology.inc

Install nefit easy http server on synology nas using ssh and type sudo -i
npm i nefit-easy-http-server -g

Run the nefit easy http server as test
easy-server --serial=serialnumber --access-key=enteryourkey --password=enteryourpassword

Check if you can reach the http server using the following command:
curl http://127.0.0.1:3000/bridge/ecus/rrc/uiStatus

Go to domoticz which is running on my synology server
Add new hardware
Nefit easy http server over lan interface
enter by the section remote address your localhost address which is normally 127.0.0.1 for your nas device, the name for remote address sounds a bit weird to me in this case but use your localhost ip.
name: nefit-easy
Remote address: 127.0.0.1
poort: 3000


Go to Devices and check if there are nefit devices available and add the devices to the dashboard! :D

if there are no devices available check the logging in domoticz and verify with curl if the easy http server is running.


Create Startup script called easy-server.sh and place it in the directory /usr/local/etc/rc.d/

Please make sure you name it easy-server.sh and change the rights so it is executeable. sudo chmod 755 easy-server.sh

test the script sudo ./easy-server.sh start

netstat -a |grep 3000 tcp 0 0 localhost:3000 0.0.0.0:* LISTEN

Reboot the nas and check that the process is running.
ps -aux | grep easy-http


@thanks to mvveelen

I edit the scriptname directory because of the change in DSM 6.0.2

#! /bin/sh ### BEGIN INIT INFO # Provides: nefit easy http server # Required-Start: $network $remote_fs $syslog # Required-Stop: $network $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: nefit-easy-http-server # Description: This daemon will start the nefit-easy-http-server for use by Domoticz ### END INIT INFO # Do NOT "set -e" PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin DESC="Nefit Easy HTTP Server" NAME=easy-server USERNAME=root PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/usr/local/etc/rc.d/$NAME NEFIT_SERIAL_NUMBER=ENTERSERIAL NEFIT_ACCESS_KEY=ENTERKEY NEFIT_PASSWORD=ENTERPASSWORD NEFIT_HOST=127.0.0.1 NEFIT_PORT=3000 DAEMON=/usr/local/bin/$NAME DAEMON_ARGS="$DAEMON_ARGS --serial=$NEFIT_SERIAL_NUMBER" DAEMON_ARGS="$DAEMON_ARGS --access-key=$NEFIT_ACCESS_KEY" DAEMON_ARGS="$DAEMON_ARGS --password=$NEFIT_PASSWORD" DAEMON_ARGS="$DAEMON_ARGS --host=$NEFIT_HOST" DAEMON_ARGS="$DAEMON_ARGS --port=$NEFIT_PORT" # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 # # Function that starts the daemon/service # do_start() { nohup $DAEMON $DAEMON_ARGS & echo `ps w | grep ${DAEMON} | grep -v -E 'grep' | awk '{print $1}' > $PIDFILE` } wait_for_status () { counter=$2 while [ ${counter} -gt 0 ]; do do_status [ $? -eq $1 ] && return let counter=counter-1 sleep 1 done return 1 } # # Function that stops the daemon/service # do_stop() { # Kill the application kill `cat ${PIDFILE}` wait_for_status 1 20 || kill -9 `cat ${PIDFILE}` rm -f ${PIDFILE} } do_status () { if [ -f ${PIDFILE} ] && kill -0 `cat ${PIDFILE}` > /dev/null 2>&1; then return fi rm -f ${PIDFILE} return 1 } case "$1" in start) do_start ;; stop) do_stop ;; restart) do_stop do_start ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2 exit 3 ;; esac :