OpenHAB2 + Razberry + Z-Wave Binding

Tags: #<Tag:0x00007f173fcda8b8> #<Tag:0x00007f173fcda7f0>

Hey Chris,

So I am trying to get DEBUG going - I have visited
http://www.cd-jackson.com/index.php/openhab to try to get it enabled. By
console, do you mean a shell session is where I enter this at the
prompt *log:set
debug org.openhab.binding.zwave? *I am getting an error. I am new to OH2,
so all of this is still foreign.

Thanks for working with me,

Bud

It looks like I can get some feedback running the start_debug.sh. After doing so, and after editing the
([Solved] How to define a serial port on raspberry for openhab2 for my razberry zwave binding?)

setenv

in file “setenv” at /opt/openhab/runtime/karaf/bin
you need to add the parameter -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0
just to make sure that karaf is aware on the JVM parameter.

for me those are now:

export JAVA_OPTS="${JAVA_OPTS}
-Dopenhab.home=${OPENHAB_HOME}
-Dopenhab.conf=${OPENHAB_CONF}
-Dopenhab.runtime=${OPENHAB_RUNTIME}
-Dopenhab.userdata=${OPENHAB_USERDATA}
-Dorg.osgi.service.http.port=${HTTP_PORT}
-Dorg.osgi.service.http.port.secure=${HTTPS_PORT}
-Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0"

still no dice.

So is there another way to define the serial port in OH2?

Resolved. It was a syntax error.

For those using the Razberry board, it seems that this line -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0" needs to be added to /usr/share/openhab2/runtime/karaf/bin/setenv under

export JAVA_OPTS="${JAVA_OPTS}

at the end and the ending quote needs to be removed after -Dorg.osgi.service.http.port.secure=${HTTPS_PORT}".

export JAVA_OPTS="${JAVA_OPTS}
-Dopenhab.home=${OPENHAB_HOME}
-Dopenhab.conf=${OPENHAB_CONF}
-Dopenhab.runtime=${OPENHAB_RUNTIME}
-Dopenhab.userdata=${OPENHAB_USERDATA}
-Dorg.osgi.service.http.port=${HTTP_PORT}
-Dorg.osgi.service.http.port.secure=${HTTPS_PORT}
-Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0"

Thanks for the help @chris and @peter_seelinger.

Debugging still seems to be a mystery, but I will keep tinkering.

What is the error?

Note that starting with the debug script still won’t enable debugging until you enable it in the console.

I am under the impression I can type log:set debug org.openhab.binding.zwave at the SSH shell. When I do that, I receive the error -bash: log:set: command not found.

Thanks @chris

This command should work. Are you logged in to the correct console? What do you see when you log on (do you see the openhab logo), and what do you see when you type ‘help’ (eg lots of OH commands)?

Got it resolved by launching ./client
Thanks @chris - you’ve been great.

I seem to be struggling with OpenHab 2 connecting to the Razberry board. I had it working a few months ago with a manual installation of the beta, but due to a corrupted SD card I lost that work.

The difference this time is that I installed OpenHAB2 as a service.

The z-wave network was setup using the Z-way software, as I did last time. I then stopped the z-way-server service before starting the OpenHab2 service.

I added the line to the setenv file under /usr/share/… , making sure the ’ " ’ was in the right place. Still no dice, however. Upon start up OpenHab2 does not recognize ttyAMA0.

Hi I’ve also experienced issues with this.
See: /dev/ttyAMA0 does not exist on RasPi2 & OH2

Basically for me it works when using /dev/ttyUSB30 in the configuration of the Z-wave controller:

root@firefly:/dev# ls -l tty*USB*
lrwxrwxrwx 1 root root 7 Sep  5 20:38 ttyUSB30 -> ttyAMA0
root@firefly:/dev# ls -la *ttyAMA0*
crw-rw---- 1 root dialout 204, 64 Sep  9 09:49 ttyAMA0

Where ttyUSB30 is a symbolic link.

Hi @Seaside, thank for your response.

I created the symbolic link as per that thread, and changed the setenv file and the openhab config to reflect that change.

I rebooted the OpenHab2 service, but now it just says /dev/ttyUSB30 does not exist.

pi@raspberrypi ~ $ ls -l /dev/tty* crw-rw---- 1 root tty 204, 64 Dec 31 1969 /dev/ttyAMA0 lrwxrwxrwx 1 root root 12 Sept 9 06:57 /dev/ttyUSB30 -> /dev/ttyAMA0

Do I need to restart the pi for these changes to work?

Edit: Just tried rebooting, and adding user pi and openhab to group tty. Still no change.

Edit2: I was finally able connect. The answer was staring me in the face. Adding user pi to group tty was what I needed, combined with @budghiss 's solution.

Hi Connor,

I have not been using OH2 lately, I reverted back to OH1 for the time being.

I as well believe I used z-way before launching OH2 - this may not be
mandatory though.

To get z-way working properly, I had to use:

echo 900 >
/opt/z-way-server/automation/storage/8084AccessTimeout-6b497208061ec7faae003cdd7f9a035e.json

As for OH2, I made a short script to try to step through the install.

Also, this script has the offline version - you should now be able to use
apt-get.

Let me know if this helps.

#!/bin/bash

sudo apt-get install apt-transport-https

sudo echo deb
https://openhab.ci.cloudbees.com/job/openHAB-Distribution/ws/distributions/openhab-offline/target/apt-repo/
/ >> /etc/apt/sources.list
sudo apt-get install openhab2-offline

sudo chown -hR openhab:openhab /etc/openhab2
sudo chown -hR openhab:openhab /usr/share/openhab2

sudo apt-get install samba samba-common-bin

sudo cp -v smb.conf /etc/samba/

#verify /etc/samba/smb.conf -> wins support = yes and openhab parameters
are set at bof

sudo smbpasswd -a openhab

sudo update-rc.d smbd enable
sudo update-rc.d nmbd enable
sudo service smbd restart

sudo usermod -a -G dialout openhab
sudo usermod -a -G dialout pi
sudo usermod -a -G dialout root
sudo usermod -G tty openhab

#edit  /usr/share/openhab2/runtime/karaf/bin/setenv to
#export JAVA_OPTS="${JAVA_OPTS}
#-Dopenhab.home=${OPENHAB_HOME}
#-Dopenhab.conf=${OPENHAB_CONF}
#-Dopenhab.runtime=${OPENHAB_RUNTIME}
#-Dopenhab.userdata=${OPENHAB_USERDATA}
#-Dorg.osgi.service.http.port=${HTTP_PORT}
#-Dorg.osgi.service.http.port.secure=${HTTPS_PORT}
#-Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0"

Rob

Hi Rob,

Thanks for taking the time to send me that info.

I had previously added openhab and pi users to dialout, but I hadn’t to
tty. Once I did that I was able to connect to AMA0.

Thanks again,

Connor

Hi,

i have the same problem after updating to openhab2, i did not find the folder /openhab2/runtime/karaf/bin/setenv.

maybe it is wrong by me?

can you give me some advices?

thanks alot

I found it (in OpenHABian) under
/usr/share/openhab2/runtime/bin/setenv

  1. disable the tty an the GPIO UART with raspi-config, reboot
  2. set “enable-uart=1” in /boot/config.txt, reboot
  3. /dev/ttyAMA0 should be accessable again (check group of device versus groups of openhab user)

Thanks Frerk, i found it and try to connect to my razberry v.2. Do you have any problems after changing the file setenv? Can you connect with your Razberry?

Quang-Tuyen Tran
quangtuyen.tran@gmx.de
(+49) 015237376688

Yes I got it working.
But I forgot that I had to

  1. install librxtx-java
  2. add /usr/lib/jni als java Library path to the JAVA_OPTS in setenv
  3. add /dev/ttyAMA0 as serial line to JAVA_OPTS as well

I write a better tutorial when I have time and direct access to my raspberry pi.

Good luck,

Frerk

Please do not edit the setenv file. It will be overwritten on upgrades!

As you can find out in the documentation, there is an extra file intended for these changes:
http://docs.openhab.org/installation/linux.html#privileges-for-common-peripherals


Regarding the Razberry and openHABian: There is a menu entry in openhabian-config: openHABian hassle-free openHAB Setup - you do not need to do anything else!


On any other Raspbian system you will have to do the following:

  • Execute adduser openhab dialout and adduser openhab tty
  • Remove the serial console and login shell from /boot/cmdline.txt and /etc/inittab as shown here and here
  • Enable the serial port by adding “enable_uart=1” to /boot/config.txt
  • Disable Bluetooth on the RPi3 by adding “dtoverlay=pi3-miniuart-bt” to /boot/config.txt
  • Add to file /etc/default/openhab2:
EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyS0:/dev/ttyAMA0"

Afterwards you just need to add the appropriate serial port to your ZWave binding.

A discussion regarding the details can be found here.

4 Likes

Thank you very much for your support.

It is very clear for me and another Beginners.

Thanks again

1 Like

Hi Thom,

i am here again because of my problem after updating the lastest Openhab 2 on Openhabian.

After updating Openhab2, the Razberry on RPI 3 is offline, it said that the serial port /dev/ttyAMA0 is in used.
i tried to do like you said with using openhabian-config but it is not successful.
i controlled all files (config.txt, cmdline.txt…) again, and they are same like you worte.
i tried many times to restart the system, but not yet succesful.

i don’t know why???

in addition i can not connect to wifi with openhabian? can you give me a tutorial?

Thanks in advance,

QT. Tran