Binding Modbus 2.5.7. Stops working after unsuccessful read attempt

No you did right in copying the jar.
But you forgot to uninstall the binding in PaperUI, like rossko57 says :slight_smile:

Did the modbus binding update in 2.5.7?? (I havnt updated yet).

EDIT - Ignore the question about modbus 2.5.7 update… just read the release notes again… Its there :woozy_face:

2 Likes

I did everything as I was advised - now it works !!! I provoked an error several times, the binding “swears”, but when the channel is restored, it continues to work normally. Great job! Thank!

3 Likes

I tried using the new plugin but get the following error:

Unresolved requirement: Import-Package: org.apache.commons.pool2; version="[2.4.0,3.0.0)"

Any idea how to resolve that ?

@mvwieringen do you mean you tried to install the 2.5.8-SNAPSHOT version linked above?

Or do you get that error straight away with 2.5.7 release version?

That’s with the 2.5.8-SNAPSHOT zip extracted.

1 Like

EDIT: openhab 2.5.8 stable has been now released. The stable version is recommended for most users and the instructions below are not needed.

I made these step-by-step instructions (working at least with “manual” installation), hopefully helping others as well

  1. Confirm you have 2.5.7 versions running (Active)
openhab> bundle:list -s|grep modbus
247 │ Active │  80 │ 2.5.7                   │ org.openhab.binding.modbus
248 │ Active │  80 │ 2.5.7                   │ org.openhab.binding.modbus.sunspec
255 │ Active │  80 │ 2.5.7                   │ org.openhab.io.transport.modbus

This is important. The org.openhab.io.transport.modbus-2.5.8-SNAPSHOT.jar will not work with pre-2.5.7 org.openhab.binding.modbus/sunspec.

  1. Unzip 2.5.8-SNAPSHOT zip (see above)
  2. Copy org.openhab.io.transport.modbus-2.5.8-SNAPSHOT.jar to addons folder (for exact location, refer to https://www.openhab.org/docs/installation/linux.html#file-locations)
  3. List bundles and confirm you have 2.5.8 snapshot registered
openhab> bundle:list -s|grep modbus                                                                                                                        
259 │ Active │  80 │ 2.5.7                   │ org.openhab.binding.modbus
260 │ Active │  80 │ 2.5.7                   │ org.openhab.binding.modbus.sunspec
267 │ Active │  80 │ 2.5.7                   │ org.openhab.io.transport.modbus
268 │ Active │  80 │ 2.5.8.202007261630      │ org.openhab.io.transport.modbus
  1. Uninstall older (2.5.7) org.openhab.io.transport.modbus version, using the ID (first column) above
openhab> bundle:uninstall 267
  1. Confirm that old bundle is removed:
openhab> bundle:list -s|grep modbus                                                                                                                        
259 │ Waiting │  80 │ 2.5.7                   │ org.openhab.binding.modbus
260 │ Active  │  80 │ 2.5.7                   │ org.openhab.binding.modbus.sunspec
268 │ Active  │  80 │ 2.5.8.202007261630      │ org.openhab.io.transport.modbus

You can refresh bundle status manually:

openhab> bundle:refresh 259
openhab> bundle:list -s|grep modbus
259 │ Active │  80 │ 2.5.7                   │ org.openhab.binding.modbus
260 │ Active │  80 │ 2.5.7                   │ org.openhab.binding.modbus.sunspec
268 │ Active │  80 │ 2.5.8.202007261630      │ org.openhab.io.transport.modbus
  1. Restart openHAB & confirm that there is no old transport version running, and all the bundles are Active
openhab> bundle:list -s|grep modbus                                                                                                                        
259 │ Active │  80 │ 2.5.7                   │ org.openhab.binding.modbus
260 │ Active │  80 │ 2.5.7                   │ org.openhab.binding.modbus.sunspec
268 │ Active │  80 │ 2.5.8.202007261630      │ org.openhab.io.transport.modbus
5 Likes

EDIT: users are reporting that these steps do not necessarily work out (missing dependencies)
EDIT2: Added couple of additional steps to finish the installation and resolve the dependency issues
EDIT3: openhab 2.5.8 stable has been now released. The stable version is recommended for most users and the instructions below are not needed.

Alternatively, you can now just download SNAPSHOT versions of modbus binding and modbus transport from ci.openhab.org, and just use them

  1. Uninstall 2.5.7 modbus binding, using Paper UI
  2. Confirm uninstallation using bundle:list -s |grep modbus, no bundles should be installed
  3. Download https://ci.openhab.org/view/Integration%20Builds%20(2.5.x)/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-addons/target/openhab-addons-2.5.8-SNAPSHOT.kar
  4. rename openhab-addons-2.5.8-SNAPSHOT.kar to openhab-addons-2.5.8-SNAPSHOT.zip
  5. Unzip
  6. Find 2.5.8-SNAPSHOT versions from following locations of the extracted files:
  • /repository/org/openhab/addons/bundles/org.openhab.binding.modbus/2.5.8-SNAPSHOT/org.openhab.binding.modbus-2.5.8-SNAPSHOT.jar modbus binding
  • /repository/org/openhab/addons/bundles/org.openhab.io.transport.modbus/2.5.8-SNAPSHOT/org.openhab.io.transport.modbus-2.5.8-SNAPSHOT.jar modbus transport

In case you use the modbus.sunspec addon:

  • /repository/org/openhab/addons/bundles/org.openhab.binding.modbus.sunspec/2.5.8-SNAPSHOT/org.openhab.binding.modbus.sunspec-2.5.8-SNAPSHOT.jar
  1. Copy the 2.5.8-SNAPSHOT versions to addons
  2. Check the logs, you will probably have error there
08:08:07.785 [WARN ] [org.apache.felix.fileinstall         ] - Error while starting bundle: file:/home/salski/src/openhab-tests/openhab-2.5.7-test/addons/org.openhab.binding.modbus-2.5.8-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.modbus [205]
  Unresolved requirement: Import-Package: org.openhab.io.transport.modbus.endpoint
    -> Export-Package: org.openhab.io.transport.modbus.endpoint; bundle-symbolic-name="org.openhab.io.transport.modbus"; bundle-version="2.5.8.202008131350"; version="2.5.8"
       org.openhab.io.transport.modbus [203]
         Unresolved requirement: Import-Package: gnu.io; version="[3.12.0,6.0.0)"
  Unresolved requirement: Import-Package: org.openhab.io.transport.modbus
    -> Export-Package: org.openhab.io.transport.modbus; bundle-symbolic-name="org.openhab.io.transport.modbus"; bundle-version="2.5.8.202008131350"; version="2.5.8"; uses:="org.eclipse.smarthome.core.library.types,org.eclipse.smarthome.core.types,org.openhab.io.transport.modbus.endpoint"
  1. gnu.io dependency is missing. Install it by feature:install openhab-transport-serial, and restart the bundles using bundle:restart
openhab> feature:install openhab-transport-serial
openhab> bundle:list -s |grep modbus
203 │ Installed │  80 │ 2.5.8.202008131350      │ org.openhab.io.transport.modbus
204 │ Installed │  80 │ 2.5.8.202008131401      │ org.openhab.binding.modbus.sunspec
205 │ Installed │  80 │ 2.5.8.202008131350      │ org.openhab.binding.modbus
openhab> bundle:restart 203 204 205  # Find correct IDs above
  1. Check the logs (log:tail), you will probably have error there, slightly different this time:
	Unable to start bundle 203: Could not resolve module: org.openhab.io.transport.modbus [203]
  Unresolved requirement: Import-Package: org.apache.commons.pool2; version="[2.4.0,3.0.0)"
...
  1. org.apache.commons.pool2 dependency is missing. Install it by bundle:install, and restart the bundles using bundle:restart
openhab>bundle:install https://repo1.maven.org/maven2/org/apache/commons/commons-pool2/2.4.3/commons-pool2-2.4.3.jar  # modbus transport 2.5.7 is using apache commons pool2 v. 2.4.3 version
openhab> bundle:list -s |grep modbus
203 │ Installed │  80 │ 2.5.8.202008131350      │ org.openhab.io.transport.modbus
204 │ Installed │  80 │ 2.5.8.202008131401      │ org.openhab.binding.modbus.sunspec
205 │ Installed │  80 │ 2.5.8.202008131350      │ org.openhab.binding.modbus
openhab> bundle:restart 203 204 205  # Find correct IDs above
  1. Bundles should be now active, with no errors in logs
openhab> bundle:list -s |grep modbus
203 │ Active   │  80 │ 2.5.8.202008131350      │ org.openhab.io.transport.modbus
204 │ Active   │  80 │ 2.5.8.202008131401      │ org.openhab.binding.modbus.sunspec
205 │ Active   │  80 │ 2.5.8.202008131350      │ org.openhab.binding.modbus
openhab> log:tail
...
08:16:58.685 [INFO ] [ort.modbus.internal.ModbusManagerImpl] - Modbus manager activated
08:16:58.946 [INFO ] [ort.modbus.internal.ModbusManagerImpl] - Modbus manager activated
  1. Installation successfull
6 Likes

Tried following the description above (downloading/extracting jar files), but end up with error relating to missing requirement/import package: org.apache.commons.pool2. Running openHAB 2.5.7 Release version.

Also tried restarting bundle, with error shown below.

Error executing command: Error restarting bundles:
	Unable to start bundle 204: Could not resolve module: org.openhab.io.transport.modbus [204]
  Unresolved requirement: Import-Package: org.apache.commons.pool2; version="[2.4.0,3.0.0)"

@kjoglums did you get the error with both approaches or with just one of them?

I have only tested using the alternative described in post no 16. Started out having the binding installed via Paper UI, doing a full uninstall/clean tmp and cache etc before installing binding manually (modbus and io.transport). From manual install, the bundles are listed as “Installed”, with only one version of each listed (correct version number), but not able to get them “Active”. Have tried several reboots.

EDIT:
Also tried the approach described in post no 15, although starting out with the 2.5.7 version installed from Paper UI.

After manually installing org.openhab.io.transport.modbus-2.5.8-SNAPSHOT.jar, uninstalling the 2.5.7 version and performing OH reboot, I have the correct setup wrt versions, and the bundles seem to be working.

1 Like

Hi, I also followed your instructions and got following error. Do I need to update more packages?

2020-08-03 21:51:55.283 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.io.transport.modbus-2.5.8-SNAPSHOT.jar

org.osgi.framework.BundleException: Could not resolve module: org.openhab.io.transport.modbus [203]

  Unresolved requirement: Import-Package: gnu.io; version="[3.12.0,6.0.0)"

	at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]

	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

2020-08-03 21:51:55.633 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.modbus-2.5.8-SNAPSHOT.jar

org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.modbus [204]

  Unresolved requirement: Import-Package: org.openhab.io.transport.modbus.endpoint

    -> Export-Package: org.openhab.io.transport.modbus.endpoint; bundle-symbolic-name="org.openhab.io.transport.modbus"; bundle-version="2.5.8.202008030359"; version="2.5.8"

       org.openhab.io.transport.modbus [203]

         Unresolved requirement: Import-Package: gnu.io; version="[3.12.0,6.0.0)"

  Unresolved requirement: Import-Package: org.openhab.io.transport.modbus

    -> Export-Package: org.openhab.io.transport.modbus; bundle-symbolic-name="org.openhab.io.transport.modbus"; bundle-version="2.5.8.202008030359"; version="2.5.8"; uses:="org.eclipse.smarthome.core.library.types,org.eclipse.smarthome.core.types,org.openhab.io.transport.modbus.endpoint"

	at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]

	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

Please try the other instructions, updating only the transport. Other users as well have reported trouble updating both the binding and transport to snapshot

Thank, you. Yes it seems to work now.

But after a reboot of the raspberry (I use openhabian) the 2.5.7 transport addon is installed again.
Is it possible that it is installed automatically with the binding 2.5.7?
Thank you. BR

> openhab> bundle:list -s|grep modbus
> 202 x Active x  80 x 2.5.8.202008030359      x org.openhab.io.transport.modbus
> 210 x Active x  80 x 2.5.7                   x org.openhab.binding.modbus
> 211 x Active x  80 x 2.5.7                   x org.openhab.binding.modbus.sunspec
> 222 x Active x  80 x 2.5.7                   x org.openhab.io.transport.modbus

Heh that’s funny, it says that both versions are active… Does it stay active if you refresh the status of the bundles?

Yes it does stay active. I don`t think that is good :slight_smile: I also have some strange behavior like items are not linked to the modbus channels properly.
Do you have an idea why the 2.5.7 of the org.openhab.io.transport.modbus activates itself?

I just wanted to say that I installed v 2.5.8 of the transport as per ssalonen description (the first one) and everything works again and seems to stayed working now for a couple of days.

FYI: I do have the impression that sometimes it is slow. For example, openhab is connected by modbus to my wago plc that in it’s turn is connected to relays for blinds. When I ask openhab to close the blinds, it sets a parameter on the plc and the plc sets the relays. Before the update, I don’t remember that this was the case.

Hi @MathiasVDA, thanks for the report!

Do you mean that it takes time before blinds start to move after sending the command in openhab?

This is a bit unexpected (no functional changes how commands are processed, at least not in the binding ) but everything is possible . You should be able to verify whether it is the plc or openhab that has the delay by switching the verbose logging. You can see the delay between accepting the command and sending a modbus request to plc.

Yes that’s what I mean.

Ah interesting. I’ll try the verbose logging tonight when the kids are sleeping.

I just found out that the delay is only present after a time of not sending any commands. For example after night this mor ING when I wanted to control the blinds, there was a delay of about 10s before the blinds moved after sending the command to openhab

Oh we are talking that large delay :thinking: interesting to see the detailed logs.

Do you happen to have rules triggering the modbus command? There’s been discussions on java introducing huge delays in some configurations Rule execution lags, possibly Java GC

This is a frequently reported problem. You can probably see it by reviewing your events.log for the time. What initiates your rule? When does the rule issue a new command?

1 Like