OH2.5 has been very stable running in a Docker container on a Synology NAS for a couple of months so its time to move to on OH3. Forum searches seemed to be hit and miss without running as root and without using the host network. The following two changes have made the z-wave dongle consistently available to OH3 for me.
1). Create a udev .rules file to assign the z-wave dongle to the group that OpenHAB is running under and to give that group read/write access to the dongle.
2). Add a device mapping by exporting the OH container to a json file, editing the file to add a device mapping for the dongle, and then creating a new container by importing the json file.
The details are below. Sorry for the lengthy post.
Configuration in DSM
Use the DSM UI to create a group named “openhab”, a user named “openhab” and assign the openhab user to the openhab group.
SSH SSH configuration
SSH into the Synology and get root access with the “sudo –I” command (that’s dash lower case eye).**
Enter “id openhab” to display the openhab user.
login as: Jim
Jim@NAS's password:
Jim@NAS:~$ sudo -i
Password:
root@NAS:~# id openhab
uid=1027(openhab) gid=100(users) groups=100(users),65536(openhab)
Make note of the id numbers the user and the openhab group. In my case the user is 1027 and the group is 65536,
Using the Linux device name that the z-wave dongle is assigned to (mine is /dev/ttyACM0) enter the following command to get the Vendor Id, Product Id and Serial number of your dongle. This command should be entered all on one line.**
udevadm info -a -n /dev/ttyACM0 | grep '{serial}\|{idVendor}\|{idProduct}' | head -n3
The result will be something like
ATTRS{idVendor}=="0658"
ATTRS{serial}=="ffffffd1ffffffb2ffffffdbffffffad"
ATTRS{idProduct}=="0200"
Next, create a file named 99-usb-zwave.rules in /lib/udev/rules.d and enter the following command in the file substituting your values for mine. The command should be entered all on one line in the file. This command assigns the dongle to the openhab group and gives read/write access to the openhab group
SUBSYSTEM=="tty", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200", ATTRS{serial}=="ffffffd1ffffffb2ffffffdbffffffad", GROUP="openhab", MODE="0660"
Save the file and restart the NAS so that the change takes effect.
Docker Configuration
Ensure the “Execute container using high privilege” checkbox and the “use the same network as Docker host” checkbox are both cleared.
Set the following values on the Environment tab:
- JAVA_EXTRA_OPTS: -Duser.timezone=America/Chicago -Dgnu.io.rxtx.SerialPorts=/dev/ttyACM0
- GROUP_ID: set to the group id from the “id” command executed earlier (65536 in my case).
- USER_ID: set to the user id from the “id” command executed earlier (1027 in my case).
OpenHab configuration
Install the Z-Wave binding and set the Port Configuration in the Thing to your device (/dev/ttyACM0 in my case).
Back in the Docker UI click on the Container tab in the left hand panel then click on the OpenHAB container just created. Click Settings → Export, select the Export container settings radio button, the Export to Synology NAS radio button, and select a folder to save the exported file in. Then export the file,
Edit the exported .json file. There will be a null Devices section.
"devices" : null,
Replace the null devices section with the following, replacing /dev/ttyACM0 with your value.
"devices" : [
{ "PathOnHost": "/dev/ttyACM0",
"PathInContainer": "/dev/ttyACM0",
"CgroupPermissions": "rw"
}
],
Back in the Docker UI delete the original container that you exported from (yep, delete it). I found that if I did not delete the container attempting to map ports when creating the new container would always result in a “port in use” error message.
After the container is deleted click on Settings → import, select the json file that you just added the device mapping to, and import the file. Start the container and the Z-Wave bridge will be Online.
One final note. Save a copy of the 99-usb-zwave.rules files. The original in the /lib/udev/rules.d folder was deleted with Synology did a DSM update. With a copy of the file save somewhere it will be easy to replace it if the file is deleted again on the next update.
- Platform information:
- Hardware: _Synology RS1221+,
- OS: DSM 6.2.4, Docker 18.09.0
- Java Runtime Environment: none
- openHAB version:3.0.1