Modbus openHAB2 binding available for alpha testing

Dear Sami,

from the first post links I cannot find the jars. I can just go to
github package source or Eclipse Smarthome.
Can you please provide me an explicit link or instructions about to get
the jars?

Many thanks,

Davide

I’m not Sami but I’ll answer anyway :slight_smile:

Easiest for you is to install IoT Marketplace extension in PaperUI. After that you can find both modbus and modbus transport bundles under addons -> bindings.

/Miik

1 Like

Finally got this stuff working after spending too many hours trying to use the obsolete readwrite keywords as I only read post 24. @ssalonen you should edit that post 24 (and some other too) as obsolete!

Anyway looking forward to be able to poll at different rates which is the reason I want to try this new binding, so far I have only connected one item.

@ddozza you can find the jars for OH2.2.0 here: https://github.com/aviborg/ecl110/tree/master/OH2/addons they are downloaded from the eclipse marketplace. I wanted to be able to pull the files to my raspberry and I couldn’t figure out how to pull them to my rpi from eclipse marketplace thats why I made copies.

Again, good work with this binding @ssalonen!

2 Likes

Hi all

You can find the download url by clicking the download icon in marketplace. (Icon on the right)

Direct download links
https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/binding/org.openhab.binding.modbus/2.3.0-SNAPSHOT/org.openhab.binding.modbus-2.3.0-SNAPSHOT.jar

https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/io/org.openhab.io.transport.modbus/2.3.0-SNAPSHOT/org.openhab.io.transport.modbus-2.3.0-SNAPSHOT.jar

Best
Sami

The download links have been updated in marketplace and above, version bumped to 2.3.0-SNAPSHOT. There were also some smaller fixes implemented (Thanks @gabriel.klein)

Here i am (coming from here: Modbus RTU Drexel & Weiss <> openHAB)
i installed (meaning: i put the 2 *jar files in addon folder) the 2.2 snapshot (as i’m on OH 2.2?) and i’d like to communicate with my heating system (read AND write).

with these settings i was able to read on 1.x addon:

modbus.cfg

serial.slave1.connection=/dev/ttyAMA0:9600:8:none:1:rtu:510
serial.slave1.id=1
serial.slave1.type=input
serial.slave1.start=202
serial.slave1.length=2
serial.slave1.valuetype=int32

item

Number Raum_MB "Raumtemperatur raw" (Modbus) {modbus="slave1:0"}

with new binding i tired to setup a thing:

log says:

2017-12-27 11:03:33.492 [WARN ] [ore.thing.internal.ThingRegistryImpl] - Cannot create thing. No binding found that supports creating a thing of type 'modbus:serial'.

what’s wrong here?

Hi!

Please use the versions linked on the opening post, or use the direct download links above. 2.2-SNAPSHOT is older version than 2.3-SNAPSHOT. Please note that generally speaking binding versions can differ from openHAB versions – for example, quite many bindings are 1.x still.

Let me know how it goes with the new version.

Best,
Sami

okay, deleted 2.2*jar and added 2.3 snapshot files.
still the same problem. here’s a longer log:

openhab.log shows ~4200 rows with this output (it comes again, and again, and again)
last row is where i try to add the thing

edit: ok, after doing all these things here: Getting the Openhab2 modbus SNAPSHOT binding · aviborg/ecl110 Wiki · GitHub i was able to add a thing.

this is my serial slave:

next step, modbus data:

 Status: OFFLINE - CONFIGURATION_ERROR readStart=202, and readValueType=int32 were specified even though the data thing is child of endpoint (that is, write-only)! 

Great to hear!

For the record, I have seen the following ERROR if you update the binding on-the-go, and not restart the binding afterwards (it has been discussed in this thread as well):

2017-12-27 13:51:44.536 [ERROR] [org.openhab.io.transport.modbus     ] - [MODBUS Connection Service(247)] The activate method has thrown an exception
java.lang.IllegalArgumentException: [org.apache.commons.pool2.impl.DefaultEvictionPolicy] does not implement EvictionPolicy
    at org.apache.commons.pool2.impl.BaseGenericObjectPool.setEvictionPolicyClassName(BaseGenericObjectPool.java:618) 

I highly recommend you to use jar files from the “official” sources I mentioned. This ensures you have the latest version (the instructions refer to https://github.com/aviborg/ecl110/tree/master/OH2/addons which has the old version, containing some now-known, now-fixed, bugs). It’s also good to be safe and refer standard sources for the jar files.

Best,
Sami

i’m on 2.3 from here: https://github.com/aviborg/ecl110/tree/master/OH2/addons
please take a look at my previous post. i was editing my post when you answered!

Hi
to confirm I use the latest snapshot and it’s working as intended. One additional (sorry if again the same) question: what data type should be used for temperature readings?

/etc/openhab2/things/modbus.things
Bridge modbus:tcp:HVAC [ host=“192.168.8.199”, port=502, id=2 ] {

//902 Supply temperature RO signed short -500 - 1200 x10 C
//903 Extract temperature RO signed short -500 - 1200 x10 C

Bridge poller holding [ start=902, length=2, refresh=2000, type=“holding” ] {
Thing data holding1 [ readStart=“902”, readValueType=“float32” ]
Thing data holding2 [ readStart=“903”, readValueType=“uint16” ]
}
}

I get this: (events.log)
2017-12-27 15:25:17.320 [vent.ItemStateChangedEvent] - holding1 changed from 0.000000000000000000000000000000000000019469202256909675 to 0.00000000000000000000000000000000000001946920085561121
2017-12-27 15:25:17.356 [vent.ItemStateChangedEvent] - holding2 changed from 55 to 54

if I change “Thing data holding1” to readValueType=“uint16”:
I get this: (events.log)
2017-12-27 15:23:52.784 [vent.ItemStateChangedEvent] - holding1 changed from 212 to 211
2017-12-27 15:23:54.999 [vent.ItemStateChangedEvent] - holding2 changed from 54 to 55

so as far as I can check on my vent unit, its 19.4 degrees of celsius :slight_smile:

thanks a lot for pointing if I miss something.

It’s indeed invalid configuration, in order to read data, you need to define poller. See “Supported things” in README:

[data thing] is responsible of converting openHAB commands to Modbus write requests. Is child of poller (read-only or read-write things) or tcp/serial (write-only things).

So set-up a Poller, and make it parent of data.

Best,
Sami

P.s. It’s still unclear to me what jar you are using. You talk about 2.3.0 but link 2.2.0 snapshot bindings

@ArC thanks for the question!

These things are highly dependent on device manufacturera and the conventions differ. The good news is that the binding is pretty flexible, and should cover the known cases pretty well. You just have to refer to the manual for details.

How do you interpret this equation (?) yourself? The formatting is a bit off? Does it describe some sort of equation?

In order to apply equations to read number, you can use transformation. The readme has an example of scaling the number read, for example, 123 in register would be interpreted as 12.3. Now the question is what kind of equation to use…

Best,
Sami

I’ll take a guess it means to expect a register value between -500 and +1200, representing -50C to +120C.
We’ve no way to tell what format the value comes in, but you could try out as signed integer and see what you get

In your log, 212 looks like reasonable indoor temperature needing a divide-by-ten, see the scaling already pointed to.

ok, next try:
serial slave (no idea why serial port is listed / displayed twice?):

regular poller:

data:

i get values, but i’m sure the values are wrong (temperatures - i have them on a display). shouldn’t i get the values for register 202?

thanks @ssalonen ! played a little bit more and found that I was needed to adjust the registers in order to read the “right one” :slight_smile:

Adjusted to:
Bridge modbus:tcp:HVAC [ host=“192.168.8.199”, port=502, id=1 ] {

//Register-902 Supply temperature RO signed short -500 - 1200 x10 C
//Register-903 Extract temperature RO signed short -500 - 1200 x10 C

Bridge poller holdingP1 [ start=901, length=1, refresh=2000, type=“holding” ] {
Thing data holding1 [ readStart=“901”, readValueType=“int16”, readTransform=“JS(divide10.js)” ]
}
Bridge poller holdingP2 [ start=902, length=1, refresh=2000, type=“holding” ] {
Thing data holding2 [ readStart=“902”, readValueType=“int16”, readTransform=“JS(divide10.js)” ]
}
}

and get nice readings:
2017-12-27 20:22:29.925 [vent.ItemStateChangedEvent] - holding1 changed from 19.1 to 19.2
2017-12-27 20:23:17.126 [vent.ItemStateChangedEvent] - holding2 changed from 21.5 to 21.4

And the last question related to Register readings: say I have below named in the manual:
Registers 906-907 “Current supply flow” RO unsigned int 0 - 200000 m3/h, l/s

how I should make my Number item to store this data read from 2 registers (906 and 907)? should I combine it somehow? sorry, I’m new - that’s why asking.

regards

You can try unsigned 32 bit integer, uint32. That spans over two 16 bit registers.

Best
Sami

Since the value type is int32, you are actually getting registers 202 and 203 combined to single signed integer. Is this what you want?

Good point regarding two serial devices, have to test it my self. Does not sound correct.

Interesting idea. Will let you know tomorrow after testing it out.
As long it shows the amount of air flow (m3/h) an integer is from 0 to 300 “my case”. Nevertheless will check.

Regards

@narf27 checked the issue with two serial devices. I can reproduce it with other bindings as well, e.g. zwave. Must be an openHAB core / ESH issue. I wonder if it is reported already…

Best,
Sami