[Solved] How to define a serial port on raspberry for openhab2 for my razberry zwave binding?

i using latest builds with openhab2. in zwave.cfg, the port is configured with
port=/dev/ttyAMA0

The openhab.log on openhab2 shows…
2016-01-24 11:44:06.055 [INFO ] [ve.internal.protocol.ZWaveController] - Connecting to serial port /dev/ttyAMA0
2016-01-24 11:44:07.016 [ERROR] [ve.internal.protocol.ZWaveController] - Serial Error: Port /dev/ttyAMA0 does not exist
2016-01-24 11:44:07.038 [ERROR] [org.apache.felix.configadmin ] - [org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService, id=283, bundle=166/mvn:org.openhab.binding/org.openhab.binding.zwave/1.9.0-SNAPSHOT]: Updating property port of configuration org.openhab.zwave caused a problem: Port /dev/ttyAMA0 does not exist
org.osgi.service.cm.ConfigurationException: port : Port /dev/ttyAMA0 does not exist
at org.openhab.binding.zwave.internal.ZWaveActiveBinding.initialise(ZWaveActiveBinding.java:311)[166:org.openhab.binding.zwave:1.9.0.201601240211]
at org.openhab.binding.zwave.internal.ZWaveActiveBinding.updated(ZWaveActiveBinding.java:406)[166:org.openhab.binding.zwave:1.9.0.201601240211]

Looks like i a missing something. On openhab1 it was required in start.sh to have the command line with

java -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0

How should i configure the serial port with openhab2 on raspberry?

In my case (Raspberry Pi 2, Raspbian Jessie, OH2 build #99, Zwave.me USB Stick) I didn’t have to configure anything like that.

You just have to pick the right port (in my case it was the same port as OH1 was using).

Although for test purposes I run OH2 as user root at the moment, maybe that is the difference?

Good luck.

Hi sihui,
thanks for your help. i am also running OH2 as root, so that should not be the issue.
i have not mentioned that am using raspbian wheezy with the razberry, which is directly plugged on the GPIO.

Regards,

Aahhh, you are using the razberry board … maybe the setup is totally differen to my usb stick …

i got it solved ! - Razberry is recognized by openhab2.


2016-01-29 23:24:45.232 [INFO ] [ve.internal.protocol.ZWaveController] - Starting Z-Wave controller
2016-01-29 23:24:45.248 [INFO ] [ve.internal.protocol.ZWaveController] - Z-Wave timeout is set to 5000ms. Soft reset is false.
2016-01-29 23:24:45.258 [INFO ] [ve.internal.protocol.ZWaveController] - Connecting to serial port /dev/ttyAMA0
2016-01-29 23:24:46.161 [INFO ] [ve.internal.protocol.ZWaveController] - Serial port is initialized

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"

@davy Could we think of some way to specify such ports without having to edit the internal/read-only file /opt/openhab/runtime/karaf/bin?

We can add an OPENHAB_JAVA_OPTS env variable.
[Issue] (https://github.com/openhab/openhab-distro/issues/109) created.

It turns out, there already is an environment variable that can be used:

export EXTRA_JAVA_OPTS=-Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0

I’ll create a PR for updating the documentation.

When using Karaf it is possible and completely legal to define system properties in etc/system.properties file.

Yes, but when using openHAB, it is illegal to mess around inside the “runtime” folder as these are considered system files that have to stay as they are :slight_smile:

There is a way to externalize part of this file with ${includes} macro if we are sure that certain file or files will exist. In case if files which are refered from macro are not mandatory it is possible to use ${optionals}. Then etc/system.properties inside OpenHab runtime needs to contain this line:
${optionals}= ../conf/system.properties
(going up from runtime which is karaf.base and steping into conf dir which is next to runtime).

Cheers,
Lukasz

Thanks @splatch, that’s good to know. For this issue here, the EXTRA_JAVA_OPTS is imho a good solution, but we might need the optionals for other things in future.

Please notice - if we use the razberry board and declare the seriel port with the java-option “Dgnu.io …” all other serial ports will be unknown. If someone use the USB0 for enocean he must edit the jave options: “Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0:/dev/ttyUSB0”. With OH 1.x this works fine - i hope in OH 2 just as well. :slightly_smiling:

Thank you for the tip. I’ve managed to get a bit further with my OH setup with this, however, I still cannot see my zwave devices (using HABmin 2.0).

Also, is it normal that I cannot see zwave binding under the bindings in OH2?

zwave_log.pdf (17.3 KB)

Is it still an issue with the serial port or anything else?

I’m having odd issues as well with my razbery. The log is full of activity and I see xml files for some of my nodes in the userdata/zwave folder but I can’t select any binding in the setup wizard, bore really do anything. then eventually the ui becomes unresponsive.

I can’t seem to figure out where I need to add this export EXTRA_JAVA_OPTS command. I’m currently running Openhab2 on a raspberry pi setup using the OpenhabianPi install. Everywhere I’ve tried putting the export command, it does not take effect for the automatically started Openhab service.

I tried adding the port to the following file…
/usr/share/openhab2/runtime/karaf/bin/setenv
It worked when starting manually but not via the service.

In the end I went for a far simpler option of giving the openhab user permission to access those ports with the following command.

sudo adduser openhab dialout

Edit the EXTRA_JAVA_OPTS environment variable defined in the /etc/default/openhab2 file.

If this file does not exist on your system check your startup file (eg /etc/init.d/openhab2). This will allow you to determine the path for a file that loads user defined environment variables.

Running (OpenHabian, R-pi3 b+)
I’ve been lurking for a couple weeks trying to get OH2 setup on my Rpi to replace OH1 running on my PC. The biggest roadblock I see still is the serial binding I need to connect to my Optoma projector via USB–>RS232 from the pi.

For the others out there trying the same with the oh1.x serial binding, this thread has gold in it but, the:

“Edit the EXTRA_JAVA_OPTS environment variable defined in the /etc/default/openhab2 file.”

does NOT seem to work. I’ve put all my usb ports in there, and verified that the ports are running with my usb->serial dongle functioning. I have verified the users(pi, openhab, and root) all have access to the ports/dialout. At this point I still get " /dev/ttyUSB0 does not exist" error in OH2. It may have worked for OH1, but it seems like OH2 is still a bit different. The next time I have to work on this I’ll try adding it to some of the other files suggested above, and report back what I find.

disclaimer - I’m a beginner/novice user in OH, but a complete armature in Linux

I’m a n00b on this. Also on Razberry and Raspberry Pi 3. And have no clue anymore what we are attempting to do to fix.
As understand from the posts so far the problem is in all attempts to get the Razberry operational with Openhab2.
In the paper ui it states I added
zwave:serial_zstick:9c5547a1
Z-Wave Serial Controller
Z-Wave USB Stick with Serial Interface

Did I maybe just missed the complete point and should I be adding another “thing”. Is there something coming up in the future?

I tried all the above advises and get the idea that there is no working solution. Strange since z-way works out of the box. Are we sure that we are looking at the right tty port?
Maybe I need to install a driver first?

So completely lost with no clue how to continue. Who can give us a push in the right direction.