Hello everybody,
I have managed to install Domoticz on my QNAP TS-469L (without OpenZWave support). It was pretty messy and since I’m not an expert programmer, my troubleshooting along the way might have been a little unorthodox. However, I'll share my knowledge anyway and hope, that you can benefit from it.
In principle my references were these two tutorials:
Synology-Tutorial 1;
Synology-Tutorial 2. Additionally I googled all errors to find solutions. Of course you can try to begin without applying my workarounds directly and react to your errors individually.
General Problems:
The OS of QNAP is, typically for a NAS, a custom-made Linux distribution. In contrast to e.g. Debian, the available additional software, libraries, etc. that are 'ready-to-install' are not very up-to-date. This results in various challenges - for example: I still couldn't manage to get
Lua 5.2 to run which Domoticz requires since the latest version available for QNAP is 5.1.5. Scripts are triggered fine, but advanced commands like 'os.execute()' do not work [but that’s not the issue right now].
Requirements:
In order to get
Domoticz running in the end, I used some files, I only could find in the HD-Station file system. So maybe you need QNAP's HD-Station, or search for other workarounds.
You need to be able to connect to your QNAP via SSH (I used
Putty) [all code is entered there] and its handy to use a (S)FTP client as well for browsing (I used
WinSCP).
And, if you still don't have it yet, install
Optware IPKG via the 'App Center' in your QNAP browser interface (QTS). This will allow you to install some packages we need. For troubleshooting it is helpful, to log in to the IPKG browser interface (via the 'Open'-Button), where you can search for available and installed packages.
Install Packages:
Log in as 'admin' (or however your admin is named) via Putty and execute the following command in the console:
Code: Select all
ipkg update
ipkg upgrade
ipkg install wget-ssl git tar gcc make optware-devel boost-dev boost-thread boost-system
ipkg install boost-date-time boost-python libcurl-dev libusb openssl openssl-dev lua
The packages will be installed one after another. If you find out later (by reading error messages) that something is missing, just try to find and install the respective package.
Install CMake:
CMake is the program we need to install in order to build
Domoticz. (As far as I understand it,) it will tell
Domoticz where to find what on the QNAP.
In Putty, browse to a folder, where you want to store your installation packages. (I usually create folders with WinSCP and copy/paste the path into Putty (right click).) For this tutorial I use
Code: Select all
cd /share/MD1_DATA/Public/InstallationPackages # the MD1_DATA - part varies with the RAID-Config
Now we download and unpack
CMake (of course you can try your luck with a newer version):
Code: Select all
wget http://www.cmake.org/files/v3.3/cmake-3.3.1.tar.gz
tar xvf cmake-3.3.1.tar.gz
The
first issue I had with the latest version of
CMake (at that point 3.3.1) was, that it couldn't find the previously installed boost libraries. So we'll need a little workaround with an element from an older version.
I downloaded and unpacked version 2.6.4
Code: Select all
wget http://www.cmake.org/files/v2.6/cmake-2.6.4.tar.gz
tar xvf cmake-2.6.4.tar.gz
... and simply replace the file cmake-3.3.1/Modules/FindBoost.cmake from the 3.3.1 with the respective file from 2.6.4 (maybe make a backup-copy). Using the on-board Editor of WinSCP, we need to add the Boost version we have installed to line (ca.) 276 of the new-old file. In my case it was "1.45" "1.45.0" (you can find out yours via the IPKG browser interface).
The
second issue was, that
CMake couldn't find the Curses Libraries. Therefore we need to add the following two lines to the file cmake-3.3.1/Modules/FindCurses.cmake right beneath the introducing comment. Please check, if your "libncurses.so" can be found under this path, too, and alter the path respectively if necessary.
Code: Select all
set(CURSES_LIBRARY "/opt/lib/libncurses.so")
set(CURSES_INCLUDE_PATH "/opt/include")
Now
CMake is ready for its installation. Pick an installation path to use as prefix-option (otherwise it'll land in your InstallationPackages-Folder). I have chosen "/opt/cmake" (where opt is a link into the Optware-Path).
Code: Select all
cd cmake-3.3.1/
chmod +x configure # makes configure executable
chmod +x bootstrap
./configure --prefix=/opt/cmake
make
make install
# check if it worked:
/opt/cmake/bin/cmake -version
Install OpenZWave:
At this point, the support for OpenZWave needs to be installed. Since I didn't do this, I'll have to leave you alone with that. Check out the two linked Tutorials above.
Install Domoticz:
Go to your favoured installation folder. I chose /share/MD1_DATA/.qpgk/ since most of my installations are there. We'll download the git repository of
Domoticz and prepare it.
Code: Select all
cd /share/MD1_DATA/.qpgk/
git clone https://github.com/domoticz/domoticz.git domoticz # it will create a new subfolder!
cd domoticz/
git init
I didn't apply the Synology-Patch mentioned in the Synology-Tutorial. But maybe it is helpful for the QNAP as well - feel free to try it out.
During the next step, I got the following warnings and follow-up errors:
Code: Select all
c++: unrecognized option '-static-libstdc++'
# and
CmdLine.cpp:(*):undefined reference to '__sync_fetch_and_add_4'
My workaround was to alter the lines 81 to 84 of "CMakeLists.txt" (the one in the domoticz main directory) from...
Code: Select all
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++")
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -static-libstdc++")
SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static-libgcc -static-libstdc++")
... to:
Code: Select all
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc")
SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static-libgcc")
Maybe the developers can tell us which functionalities we lose by doing so.
As preparation for the building process, we need to
create a link within the domoticz/ directory to the
CMake executable (/share/MD1_DATA/.qpkg/Optware/cmake/bin/cmake), in order to be able to run
CMake from there. (Again, I used WinSCP for this.)
Now, finally, the moment has come to build
Domoticz! Since
CMake also had some trouble with finding several paths, I delivered them as options with the next command. You need to check, whether the respective paths apply to your QNAP as well. Maybe start without the options and react to the errors.
Code: Select all
./cmake -DBoost_INCLUDE_DIRS=/opt/include/boost/ -DOPENSSL_ROOT_DIR=/opt/bin/ -DOPENSSL_LIBRARIES=/opt/lib/ -DOPENSSL_INCLUDE_DIR=/opt/include/openssl/ -DCURL_LIBRARY=/usr/lib/libcurl.so.4.2.0 -DCMAKE_BUILD_TYPE=Release CMakeLists.txt
make
This process takes a while. May the Force be with you!
After successful installation, you need to prepare for the first start-up. Beneath the intro-comment of "domoticz.sh" I needed to add the following line, since some libraries didn't load:
Code: Select all
export LD_LIBRARY_PATH=/share/MD1_DATA/.qpkg/Optware/lib/:$LD_LIBRARY_PATH
Next, you can set all parameters for the start of
Domoticz in the following lines of "domoticz.sh"
Code: Select all
USERNAME=YourName
DAEMON=/share/MD1_DATA/.qpkg/domoticz/domoticz
DAEMON_ARGS="-daemon -www 8888 -sslwww 552" # fill in the ports you want to use
In order to start,
Domoticz requires several files: "vars.sh", "init-functions" and "start-stop-daemon". These can NOT be found in the regular QNAP-file system but I found them in the HD-Station ("/share/MD1_DATA/.qpkg/HD_Station/"), so I simply created links in the domoticz/ folder to those files:
Code: Select all
ln -s /share/MD1_DATA/.qpkg/HD_Station/lib/init/vars.sh ./vars.sh
ln -s /share/MD1_DATA/.qpkg/HD_Station/lib/lsb/init-functions ./init-functions
ln -s /share/MD1_DATA/.qpkg/HD_Station/share/MD1_DATA/.qpkg/HD_Station/sbin/start-stop-daemon ./start-stop-daemon
[If you don't have the HD-Station, you might need to find another solution which could be using the NAS's standard start/stop daemons and reprogramming the "domoticz.sh" respectively.]
Of course we now need to tell "domoticz.sh" where to use these links. So alter the respective sections in the file so that they look like this:
Code: Select all
# Load the VERBOSE setting and other rcS variables
# . /lib/init/vars.sh
./vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
# . /lib/lsb/init-functions
./init-functions
And finally add a "./" in front of all "start-stop-daemon" expressions and delete all "--chuid $USERNAME" entries.
This should be it! Now you (hopefully) can start
Domoticz:
Code: Select all
chmod +x domoticz.sh # only for the first-time-run to make it executable
./domoticz.sh start # start command
Additional Stuff:
In order to
update Domoticz, please refer to the tutorials, I mentioned in the beginning. (I haven't tried it yet.)
Running
Domoticz at start-up.
Running
Domoticz schedule-based. "Method 1 bis" worked fine for me. I triggered my self-made 'domoautorun.sh' script with it (which I can easily alter if necessary later on):
Code: Select all
#!/bin/sh
# make executable with chmod +x domoautorun.sh
./domoticz.sh start
Remaining Issues:
I already mentioned the
Lua version issue. (Lua scripts can be used to create custom intelligent functions for your home automation, like sending commands to your self-made gadgets.) The domoticz/ folder comprises a lua/ folder from which you are supposed to build
Lua yourself. But it's not that simple. For the QNAPs we probably need to go the complicated way in order to get version 5.2.+
shown here under "Building Lua on other systems".
I don't understand why
Domoticz needs to bring its own Lua-Package and not just uses the version that is installed on the system - the scripts have nothing to with the integral functionality of
Domoticz but only need to be triggered by it.
On start-up the "log_daemon_msg" and "log_end_msg" cannot be found (which doesn't hinder the start).
After reload, the sliders of dimmers always set themselves to 0 % although the dimmer has another/an actual value (so it’s only a graphical problem). But this issue might not only be QNAP-based.
I hope this guide is helpful to all of you and that the developers can soon create some kind of QNAP-Patch as well. So please keep the discussion alive and post your experiences.