Add Java 8, OpenHAB and Z-Wave on a Synology DiskStation OS 6.1 Virtual Machine
The following acticle describes the process of installing Java 8, OpenHAB2, Aeon Labs Z-Stick Gen5 and a Fibaro Door/Window sensor on a Synology DiskStation OS 6.1 running as VirtualBox VM.
Using a Synology DiskStation to control a home automation environment is a good choice, since it usually runs 24 hours a day. However - as cautious as I am - I would first like to use a test environment to allow the experience gained there to be used into the later installation. In particular, problems can be identified in advance. This all results in a bunch of requirements.
A very interesting controller software for home automation is OpenHAB. The advantage of OpenHAB is, on the one hand, the possibility to run it on a DiskStation and on the other hand the large number of supported home automation protocols (bindings). It is written in Java and based on the OSGi framework (Equinox) (Requirements: Install Oracle Java 8, OpenHAB).
My choice for a wireless communications standard that unites the sensors and actuators in a common network fell due to the large number of available components on Z-Wave. As a controller, the Aeon Labs Z-Stick Gen5 USB stick will be used. A Fibaro Door/Window sensor will be integrated to complete a small home automation scenario (Requirements: Install Aeon Labs Z-Stick and Fibaro Door/Window sensor).
Prerequisites
- This article assumes a Synology DiskStation DSM version 6.1 running in a VirtualBox VM
- For the ip address of your disk station the value 192.168.100.100 is assumed. You should replace this value with the actual value of your installation.
- You are logged into the DiskStation and have access via SSH and the web interface
One way to meet the prerequisites is to follow the installation procedure described in this article: Set up a Virtual Machine running Synology DiskStation OS 6.x
sudo -i
, and then enter the password of
the account used to log in.
Besides any other workarounds spread on the internet you can do the following to log into disk station via SSH:
# Suppose the ip address of your disk station is 192.168.100.100
ssh admin@192.168.100.100
admin@192.168.100.100's password: ...
admin@192.168.100.100:/$ sudo -i
Password: ... # Usually the same as the admin's password
Create a RAID Group and a Volume
- Storage Manager RAID Group Create
- Select "RAID Group for single volume or iSCSI LUN (Block Level)" Next
- RAID Type: Basic Next
- Drag your 2nd HDD (>=8GB) to the RAID Group Next OK
- Perform disk check: Yes/No Next Apply OK
- Storage Manager Volume Create
- File system: ext4 OK
Install Oracle JAVA 8
- Refer to
pcloadletter.co.uk
for detailed instructions - Create a shared folder named "public" and assign r/w permissions to user group "users"
- File Station Upload
ejdk-8uxyz-linux-i586.tar.gz
andjce_policy-8.zip
to folder "public" - Package Center Settings Package sources Add values
pcloadletter
/http://packages.pcloadletter.co.uk
- Package Center Settings General Trust level Any publisher (includes setting for manual install later on) OK
- Package Center Community Refresh Java SE Embedded 8 Install
- Due to various hints throughout the web, "Unlimited Strength JCE Policy" should be chosen when requested to select "Java Cryptographic Strength Selection" policy Next Apply OK
Install OpenHab
- Note the DSM version (6.1) to download the proper OpenHAB version
- Create shared folders
cd /volume1/public mkdir -p openHAB2/conf openHAB2/addons chmod -R 775 openHAB2
- Package Center Manual Install Choose File Select the previously downloaded openHAB .spk file (at the
time of this writing:
OpenHAB-2.1.0.004-SNAPSHOT-DSM6-syno-noarch-0.001
) "Run after Installation"If you like to take a closer look of what happens while installation of OpenHAB2, downloadopenhab-syno-spk-2.0.0.001-DSM6.zip
, extract the files and inspect file/script/installer.sh
. The next steps depend on what is already set and done after OpenHab is installed. At the time of this writing the following steps had to be executed to get a configured system. This might change in the future. -
Although the installation announces to use the folder
/volume1/public/openHab2/conf
to store configuration files if it exists, this folder is empty after the installation. In order to take advantage of having configuration files in the public folder, we mount the folders manually:cd /volume1/public/openHAB2 mount -B /volume1/@appstore/openHAB2/addons ./addons mount -B /volume1/@appstore/openHAB2/conf ./conf
- Go to the Web Interface Control Panel Group and check if groups
dialout
anduucp
exist. If not, go to the command line and enter:synogroup --add dialout openhab2 synogroup --add uucp openhab2
- Open the OpenHAB dashboard:
http://192.168.100.100:8080
You should see the "Welcome to openHAB 2 - Initial Setup" page - Go ahead and configure basic settings in OpenHAB (e.g. choosing "Recommended Setup" and "Paper UI " is a good start)
Install AeonLabs Z-Stick Gen5
- If you haven’t already, plug your controller into your Host-PC
- To pass-through the Z-Stick to your virtual machine, go to the VM guest window menu Devices USB and click on "Sigma Designs, Inc." to share the device
- The Diskstation should integrate the Z-Stick as
/dev/ttyACMx
device (where x is a number, e.g./dev/ttyACM0
,/dev/ttyACM1
, ...), hereinafter referred to as/dev/ttyACM0
. You can check the attached device by enteringls -l /dev/ttyACM*
- Create UDEV rules and a start up script to set Z-Stick device permissions on each startup (you can find a
readable version of the script at the end of this article). At command line enter (most probably you'll copy
and paste):
# UDEV rules directly echoed to the target file echo 'ACTION=="add", KERNEL=="ttyACM[0-9]*", MODE="0660", OWNER="openhab2", GROUP="dialout"' >> /lib/udev/rules.d/99-aeon-z-stick.rules chmod 755 /lib/udev/rules.d/99-aeon-z-stick.rules # Start up script directly echoed to the target file echo -e '#!/bin/sh\nstart_modules(){\n\techo ls -l /dev/tty[AU]* >> /volume1/public/zwavelog.txt\n\tchown -R root.uucp /run/lock\n\tchmod -R g+w /run/lock\n\tchown -R root.uucp /var/lock\n\tchmod -R g+w /var/lock\n}\nstop_modules(){\n\techo "do nothing"\n}\ncase "$1" in\n\tstart)\n\t\tstart_modules\n\t;;\n\tstop)\n\t\tstop_modules\n\t;;\n\t*)\n\t\techo "usage: $0 { start | stop }" >&2\n\texit 1\n\t;;\nesac\nexit 0' >> /usr/local/etc/rc.d/S98openhabzwave.sh chmod 755 /usr/local/etc/rc.d/S98openhabzwave.sh # Set owner of device once chown openhab2.dialout /dev/ttyACM0 reboot
- Wait while the DiskStation reboots and login again via ssh
Install Z-Wave binding and controller in OpenHAB
- Open the OpenHAB dashboard:
http://192.168.100.100:8080
- Open "Paper UI" Add-ons Bindings Z-Wave Binding Install
- Open "Paper UI" Configuration Things Add Things Z-Wave-Binding Z-Wave Serial Controller
- In field "Serial Port" enter
/dev/ttyACM0
Install Fibaro FGK101 Door Opening Sensor
- Prepare sensor as decribed in the manual
- Open "Paper UI" Things Z-Wave Node 2: FGK101 Door Opening Sensor
- Location Enter some informational text
- Set value of "3: Visual LED indications" to 0 to save battery
- Open "Paper UI" Things Z-Wave Node 2: FGK101 Door Opening Sensor (Click on the title)
- Activate channel "Door Sensor" by clicking on the blue radio box on the left
- Create a new item: Enter some text at "Label" and/or "Category"
- Open "Paper UI" Control Check sensor status by opening and closing the sensor the corresponding status ("Open"/"Closed") should be displayed
Start up script (readable)
#!/bin/sh
start_modules(){
echo ls -l /dev/tty[AU]* >> /volume1/public/zwavelog.txt
chown -R root.uucp /run/lock
chmod -R g+w /run/lock
chown -R root.uucp /var/lock
chmod -R g+w /var/lock
}
stop_modules(){
echo "do nothing"
}
case "$1" in
start)
start_modules
;;
stop)
stop_modules
;;
*)
echo "usage: $0 { start | stop }" >&2
exit 1
;;
esac
exit 0
Enter Karaf command line from remote
- Edit file
vi /volume1/@appstore/openHAB2/userdata/etc/org.apache.karaf.shell.cfg
- Change entry
sshHost=127.0.0.1
tosshHost=0.0.0.0
.Please be aware, that the console will now be accessible from all devices in your subnet and is only secured by the password defined in users.properties (same path). You should thereby change the password.
From OpenHAB - The Console - Try to login at command line as follows
ssh openhab@192.168.100.100 -p 8101 Password authentication Password: habopen
- Checkout some commands:
openhab> bundle:list | grep Binding # List bindings 101 | Active | 80 | 0.9.0.201703201701 | Eclipse SmartHome AutoUpdate Binding 102 | Active | 80 | 0.9.0.201703201701 | Eclipse SmartHome Core Binding XML 183 | Active | 80 | 2.1.0.201703212140 | ZWave Binding openhab> smarthome:status zwave_device_114187e7_node2_sensor_door # item name CLOSED openhab> smarthome:status zwave_device_114187e7_node2_sensor_door # opening the door should give OPEN openhab> smarthome:status zwave_device_114187e7_node2_battery_level 94 openhab> logout
Usefull commands and infos
- Path to OpenHAB2:
/volume1/@appstore/openHAB2
- Take a look at the
openhab.log
file:# Inspect the last 25 entries added tail -n 25 /volume1/@appstore/openHAB2/userdata/logs/openhab.log # Clear log cp /dev/null /volume1/@appstore/openHAB2/userdata/logs/openhab.log
- Path to Z-Wave node config xml files :
/volume1/@appstore/openHAB2/userdata/zwave
- DSM commands:
synouser
synogroup
Links:
- PcLoadLetter
https://pcloadletter.co.uk/2011/08/23/java-package-for-synology/ - Oracle Java SE Embedded Downloads
http://www.oracle.com/technetwork/java/embedded/embedded-se/downloads/index.html - Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 8 Download
http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html - OpenHAB latest release
https://github.com/openhab/openhab-syno-spk/releases/latest - Using Karaf console from remote host
https://github.com/openhab/openhab-docs/pull/38/files - OpenHAB - The Console
http://docs.openhab.org/administration/console.html - [German] Grundlegende Befehle auf der Kommandozeile
http://www.synology-wiki.de/index.php/Grundlegende_Befehle_auf_der_Kommandozeile - Z-Stick Gen 5 user manual
https://aeotec.freshdesk.com/support/solutions/articles/6000056439-z-stick-gen-5-user-manual-