By default, the serial connection on the openHAB system is done with nrjavaserial.
Unfortunately there are some issues with this provider, so some (unstable) COM-connections can lock up after a while. See here:
In my case I had big problems with the connection to my smart meter trough an optical probe. As “workaround” I had to restart the whole openHAB instance after some hours. This was very frustrating.
Now there is a “real workaround”, which I found here in the forum more or less by accident.
So I want to share this here. I am very happy with it. On my system it is working since weeks without any issues. It should work with all bindings that need a serial connection.
The way it is done is very simple. See following steps:
-
Download .jar file:
Z-Wave USB stick not working after OH 3.1 update - #14 by splatch -
Put the file into your addons folder. See here:
Installation of Add-ons | openHAB -
Login to openHAB Console. See here:
The Console | openHAB -
Check if the PureJavaComm provicer is active:
openhab> bundle:list | grep ConnectorIO
Result should be like this:
351 x Active x 80 x 3.0.0.202107051005 x ConnectorIO PureJavaComm serial port provider
-
Reboot your system.
-
Now you should be able to change the port identifier in the thing configuration:
purejavacomm uses different port identifiers (ttyUSB0) from rxtx (/dev/ttyUSB0). So in my case the prefix “/dev/” is no more needed in the configuration.
-
Your serial device should already get online and work like expected.
If you see exceptions in log or it is still unstable just uninstall rxtx bundles (la -l|grep rxtx, then remove bundle without rfc in the name).
bundle:uninstall XXX
Where XXX is the ID of your bundle.
See also here:
So at the end it should look like this.
openhab> la -l|grep rxtx
339 x Installed x 80 x 3.2.0.M3 x mvn:org.openhab.core.bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/3.2.0.M3
If you use rfc ports at the same time then they will fail without main part of rxtx.
This is it. Any comments on this are very welcome.
Please beware, I am not a Linux or openHAB specialist.
So everything I said before can be wrong. I am just explaining a way how to work with a different serial provider. In my case I am a lot more happier with the alternative.
All thanks and credits to @splatch who developed this. Thank you very much.