Posted by & filed under article.

If you are new to working with USB serial devices and are about to setup OpenHAB2 and configure your new Z-Stick, then you are the target audience of this post. Being new both to OpenHAB2 and USB serial devices I found it quite frustrating to configure the Z-Wave controller with OpenHAB2.

 

The first thing you need to know, by plugging the USB Z-Stick into a computer with a Linux operating system running will assign cause the USB to be assigned a port. When the Z-Stick is plugged inn try running:

ll /dev/ttyACM*

The wildcard is needed as the Z-Stick might be assigned to /dev/ttyACM0, /dev/ttyACM1 etc..

Okay, so this is how you locate the serial port the Z-Stick acquired, move over to OpenHAB2 and paperui. Navigate to add-ons and install the Z-Wave Binding.

paperui-bindings-zwave

When the Z-Wave Binding is install, navigate to Configurations -> Things and edit the Z-Wave Serial Controller. The only thing you need to configure is the serial port as found earlier.

configure-wave-serial-controller

 

Aight! Almost done. OpenHAB2 is configured, but is currently not allowed to read the USB port. You could quickly test it by doing a chmod 666 on the serial port, but dont do that. Instead edit the /etc/default/openhab2 file and add EXTRA_JAVA_OPTS=-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0.

# openHAB 2 service configuration
#
# Additional options for the JAVA_OPTS environment variable.
# These will be appended to the execution of the openHAB Java runtime in front of all other options.
#
# A couple of independent examples:
#   EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0"
#   EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyS0:/dev/ttyS2:/dev/ttyACM0:/dev/ttyAMA0"
#   EXTRA_JAVA_OPTS="-Djna.library.path=/lib/arm-linux-gnueabihf/ -Duser.timezone=Europe/Berlin -Dgnu.io.rxtx.SerialPorts=/dev/ttyS0"

# The ports openHAB will bind its HTTP/HTTPS web server to.
#OPENHAB_HTTP_PORT=8080
#OPENHAB_HTTPS_PORT=8443

EXTRA_JAVA_OPTS=-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0

Add openhab to dialout and tty.

sudo adduser openhab dialout
sudo adduser openhab tty

Now restart OpenHAB2 with “sudo service openhab2 restart” and you should see the Z-Stick Serial Controller come online.

Walk the extra mile

Yeah, I know… So much configuration when does it stop?! Well there is one more thing you can do. As I mentioned in the beginning you cant be sure that the serial port will change after a restart or if you re-plug the Z-Stick. There is a way you can fix this and that’s with the udev rules. You should checkout this site for a deeper understanding http://www.domoticz.com/wiki/PersistentUSBDevices

However, this is the short version for the “Aeotec Z-Stick Gen5”.

Create a new rules file.

sudo nano /etc/udev/rules.d/usb-serial.rules

Create a new entry

SUBSYSTEM=="tty", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200", SYMLINK+="ttyUSB-ZWAVE"

I have already found the idVendor and idProduct for Aeotec Z-Stick Gen5. Now reboot and the Z-Stick will be accessible via the symlink /dev/ttyUSB-WAVE.

ttyUSB-ZWAVE

Remember to update /etc/default/openhab2 and the Z-Wave Serial Controller with the symlink and you should be set.

Hope you found this helpful as I spent a lot of unnecessary time to figure out these concepts.

2 Responses to “Adding Aeotec Z-Stick Gen5 to OpenHAB2”

Leave a Reply

  • (will not be published)