Transition from Modbus1 to Modbus2. OpenHab2

Good evening. There was the following task. I wanted to switch to a new version 2.3 or 2.4 for a long time (since only it already has support for the Modbus2 version). But I came up with the following problem, I was not a professional in this topic, and in the Modbus2 version the approach changed and I don’t understand how to transfer my project. If you can help me, I will be very grateful to you.

New version


http://i68.tinypic.com/2cq0kds.jpg

http://i67.tinypic.com/2czptc.png

Old version
demo.items

Switch S1 "light-1" (ALL) {modbus="slave1:0"}
Switch S2 "light-2" (ALL) {modbus="slave1:1"}
Switch S3 "light-3" (ALL) {modbus="slave1:2"}
Switch S4 "light-4" (ALL) {modbus="slave1:3"}
Switch S5 "light-5" (ALL) {modbus="slave1:4"}
Switch S6 "light-6" (ALL) {modbus="slave1:5"}
Switch S7 "light-7" (ALL) {modbus="slave1:6"}
Switch S8 "light-8" (ALL) {modbus="slave1:7"}
Switch S9 "light-9" (ALL) {modbus="slave1:8"}
Switch S10 "light-10" (ALL) {modbus="slave1:9"}
Switch S11 "light-11" (ALL) {modbus="slave1:10"}
Switch S12 "light-12" (ALL) {modbus="slave1:11"}
Switch S13 "light-13" (ALL) {modbus="slave1:12"}
Switch S14 "light-14" (ALL) {modbus="slave1:13"}
Switch S15 "light-15" (ALL) {modbus="slave1:14"}
Switch S16 "light-16" (ALL) {modbus="slave1:15"}
Switch S17 "light-17" (ALL) {modbus="slave1:16"}
Switch S18 "light-18" (ALL) {modbus="slave1:17"}
Switch S19 "light-19" (ALL) {modbus="slave1:18"}
Switch S20 "light-20" (ALL) {modbus="slave1:19"}

Switch S111 "Turn off all"
Switch S777 "Turn off"

demo.rules

rule "KitOff"
    when
            Item S111 changed from OFF to ON or
    then

                    sendCommand(S1, OFF)
                    sendCommand(S2, OFF)
                    sendCommand(S3, OFF)
                    sendCommand(S111, OFF)

    end
rule "AllOff"
    when
            Item S777 changed from OFF to ON or
    then

                    sendCommand(S1, OFF)
                    sendCommand(S2, OFF)
                    sendCommand(S3, OFF)
                    sendCommand(S4, OFF)
                    sendCommand(S5, OFF)
                    sendCommand(S6, OFF)
                    sendCommand(S7, OFF)
                    sendCommand(S8, OFF)
                    sendCommand(S9, OFF)
                    sendCommand(S10, OFF)
                    sendCommand(S11, OFF)
                    sendCommand(S12, OFF)
                    sendCommand(S13, OFF)
                    sendCommand(S14, OFF)
                    sendCommand(S15, OFF)
                    sendCommand(S16, OFF)
                    sendCommand(S17, OFF)
                    sendCommand(S18, OFF)
                    sendCommand(S19, OFF)
                    sendCommand(S20, OFF)
                    sendCommand(S777, OFF)

    end

demo.sitemaps

sitemap demo label="Op2"
{
Frame label="light" {
         Text label="Kitchen"  icon="Household-Kitchen-icon"{
			Switch item=S1
			Switch item=S2
		    Switch item=S3
		    Switch item=S111
         }
         Text label="Tv" icon="tv" {

      		Switch item=S7
		    Switch item=S8
      		Switch item=S4
		    Switch item=S5
		    Switch item=S6

         }
          Text label="Baby" icon="Baby_Pacifier" {
          Switch item=S10
          Switch item=S9
		  Switch item=S11

         }
         Text label="bed" icon="bed" {

         	Switch item=S12
		    Switch item=S13
		    Switch item=S14
         }
         Text label="batht" icon="bathtub5-1" {
		    Switch item=S16
		    Switch item=S15
         }
          Text label="sh" icon="sh-icon" {
   Switch item=S18
		     Switch item=S17
         }
         Text label="Door" icon="Door-icon" {

                Switch item=S19
                Switch item=S20
                Switch item=S777
         }
    }

Modbus Binding

modbus:tcp.slave1.connection=10.1.1.184
modbus:tcp.slave1.length=21
modbus:slave1.valuetype=bit
modbus:tcp.slave1.type=coil

Such settings, at least an example for a single switch. The man who helped me unfortunately disappeared.

I’m not familiar with OH 1.x bindings. I started with OH2.x

What I’ve done:

modbus.things

Bridge modbus:tcp:ADAM6050_01 [ host="1.2.3.4", port=502, id=1 ]
{
    // These correspond to input register numbers 00001 - 00012
    // documentation not clear for me, if I use discrete if always start by 0
    // and discrete means read only
    Bridge poller discreteInputs [ start=0, length=12, refresh=500, type="discrete" ]
    {
        Thing data di00 [ readStart="0",  readValueType="bit" ]
        Thing data di01 [ readStart="1",  readValueType="bit" ]
        Thing data di02 [ readStart="2",  readValueType="bit" ]
        Thing data di03 [ readStart="3",  readValueType="bit" ]
        Thing data di04 [ readStart="4",  readValueType="bit" ]
        Thing data di05 [ readStart="5",  readValueType="bit" ]       
        Thing data di06 [ readStart="6",  readValueType="bit" ]
        Thing data di07 [ readStart="7",  readValueType="bit" ]
        Thing data di08 [ readStart="8",  readValueType="bit" ]
        Thing data di09 [ readStart="9",  readValueType="bit" ]
        Thing data di10 [ readStart="10", readValueType="bit" ]
        Thing data di11 [ readStart="11", readValueType="bit" ]
    }

    // this is for r/w starting at 40001 to 400024
    // If I do not use holding it cannot get 40000 values
    Bridge poller holdingCounters [ start=0, length=24, refresh=500, type="holding" ]
    {
        Thing data co00 [ readStart="0",  readValueType="int32_swap" ]
        Thing data co01 [ readStart="2",  readValueType="int32_swap" ]
        Thing data co02 [ readStart="4",  readValueType="int32_swap" ]
        Thing data co03 [ readStart="6",  readValueType="int32_swap" ]
        Thing data co04 [ readStart="8",  readValueType="int32_swap" ]
        Thing data co05 [ readStart="10", readValueType="int32_swap" ]       
        Thing data co06 [ readStart="12", readValueType="int32_swap" ]
        Thing data co07 [ readStart="14", readValueType="int32_swap" ]
        Thing data co08 [ readStart="16", readValueType="int32_swap" ]
        Thing data co09 [ readStart="18", readValueType="int32_swap" ]
        Thing data co10 [ readStart="20", readValueType="int32_swap" ]
        Thing data co11 [ readStart="22", readValueType="int32_swap" ]
    }

    // r/w beginning 00034 to 00078
    Bridge poller coilsClears [ start=32, length=48, refresh=500, type="coil" ]
    {
        Thing data cl00 [ writeStart="33", writeValueType="bit", writeType="coil" ]
        Thing data cl01 [ writeStart="37", writeValueType="bit", writeType="coil" ]
        Thing data cl02 [ writeStart="41", writeValueType="bit", writeType="coil" ]
        Thing data cl03 [ writeStart="45", writeValueType="bit", writeType="coil" ]
        Thing data cl04 [ writeStart="49", writeValueType="bit", writeType="coil" ]
        Thing data cl05 [ writeStart="53", writeValueType="bit", writeType="coil" ]
        Thing data cl06 [ writeStart="57", writeValueType="bit", writeType="coil" ]
        Thing data cl07 [ writeStart="61", writeValueType="bit", writeType="coil" ]
        Thing data cl08 [ writeStart="65", writeValueType="bit", writeType="coil" ]
        Thing data cl09 [ writeStart="69", writeValueType="bit", writeType="coil" ]
        Thing data cl10 [ writeStart="73", writeValueType="bit", writeType="coil" ]
        Thing data cl11 [ writeStart="77", writeValueType="bit", writeType="coil" ]
    }   
}

My items:

Contact ADAM6050_01_DI00            "Digital Input index  0 [%s]"    (gMAPDB) { channel="modbus:data:ADAM6050_01:discreteInputs:di00:contact" }
Contact ADAM6050_01_DI01            "Digital Input index  1 [%s]"    (gMAPDB) { channel="modbus:data:ADAM6050_01:discreteInputs:di01:contact" } 
Contact ADAM6050_01_DI02            "Digital Input index  2 [%s]"    (gMAPDB) { channel="modbus:data:ADAM6050_01:discreteInputs:di02:contact" } 
Contact ADAM6050_01_DI03            "Digital Input index  3 [%s]"    (gMAPDB) { channel="modbus:data:ADAM6050_01:discreteInputs:di03:contact" } 
Contact ADAM6050_01_DI04            "Digital Input index  4 [%s]"    (gMAPDB) { channel="modbus:data:ADAM6050_01:discreteInputs:di04:contact" } 
Contact ADAM6050_01_DI05            "Digital Input index  5 [%s]"    (gMAPDB) { channel="modbus:data:ADAM6050_01:discreteInputs:di05:contact" } 
//Contact ADAM6050_01_DI06            "Digital Input index  6 [%s]"    (gMAPDB) { channel="modbus:data:ADAM6050_01:discreteInputs:di06:contact" } 
//Contact ADAM6050_01_DI07            "Digital Input index  7 [%s]"    (gMAPDB) { channel="modbus:data:ADAM6050_01:discreteInputs:di07:contact" } 
//Contact ADAM6050_01_DI08            "Digital Input index  8 [%s]"    (gMAPDB) { channel="modbus:data:ADAM6050_01:discreteInputs:di08:contact" } 
//Contact ADAM6050_01_DI09            "Digital Input index  9 [%s]"    (gMAPDB) { channel="modbus:data:ADAM6050_01:discreteInputs:di09:contact" } 
//Contact ADAM6050_01_DI10            "Digital Input index 10 [%s]"    (gMAPDB) { channel="modbus:data:ADAM6050_01:discreteInputs:di10:contact" } 
//Contact ADAM6050_01_DI11            "Digital Input index 11 [%s]"    (gMAPDB) { channel="modbus:data:ADAM6050_01:discreteInputs:di11:contact" } 

//Number ADAM6050_01_CO00             "Counter 0  [%d]"                (gMAPDB) { channel="modbus:data:ADAM6050_01:holdingCounters:co00:number" } 
//Number ADAM6050_01_CO01             "Counter 1  [%d]"                (gMAPDB) { channel="modbus:data:ADAM6050_01:holdingCounters:co01:number" } 
//Number ADAM6050_01_CO02             "Counter 2  [%d]"                (gMAPDB) { channel="modbus:data:ADAM6050_01:holdingCounters:co02:number" } 
//Number ADAM6050_01_CO03             "Counter 3  [%d]"                (gMAPDB) { channel="modbus:data:ADAM6050_01:holdingCounters:co03:number" } 
//Number ADAM6050_01_CO04             "Counter 4  [%d]"                (gMAPDB) { channel="modbus:data:ADAM6050_01:holdingCounters:co04:number" } 
//Number ADAM6050_01_CO05             "Counter 5  [%d]"                (gMAPDB) { channel="modbus:data:ADAM6050_01:holdingCounters:co05:number" } 
Number ADAM6050_01_CO06             "Counter 6  [%d]"                (gMAPDB) { channel="modbus:data:ADAM6050_01:holdingCounters:co06:number" } 
Number ADAM6050_01_CO07             "Counter 7  [%d]"                (gMAPDB) { channel="modbus:data:ADAM6050_01:holdingCounters:co07:number" } 
Number ADAM6050_01_CO08             "Counter 8  [%d]"                (gMAPDB) { channel="modbus:data:ADAM6050_01:holdingCounters:co08:number" } 
Number ADAM6050_01_CO09             "Counter 9  [%d]"                (gMAPDB) { channel="modbus:data:ADAM6050_01:holdingCounters:co09:number" } 
Number ADAM6050_01_CO10             "Counter 10 [%d]"                (gMAPDB) { channel="modbus:data:ADAM6050_01:holdingCounters:co10:number" } 
Number ADAM6050_01_CO11             "Counter 11 [%d]"                (gMAPDB) { channel="modbus:data:ADAM6050_01:holdingCounters:co11:number" } 

//Switch ADAM6050_01_CL00             "Clear Counter 0  [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl00:switch" }
//Switch ADAM6050_01_CL01             "Clear Counter 1  [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl01:switch" }
//Switch ADAM6050_01_CL02             "Clear Counter 2  [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl02:switch" }
//Switch ADAM6050_01_CL03             "Clear Counter 3  [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl03:switch" }
//Switch ADAM6050_01_CL04             "Clear Counter 4  [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl04:switch" }
//Switch ADAM6050_01_CL05             "Clear Counter 5  [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl05:switch" }
Switch ADAM6050_01_CL06             "Clear Counter 6  [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl06:switch", expire="1s,command=OFF" }
Switch ADAM6050_01_CL07             "Clear Counter 7  [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl07:switch", expire="1s,command=OFF" }
Switch ADAM6050_01_CL08             "Clear Counter 8  [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl08:switch", expire="1s,command=OFF" }
Switch ADAM6050_01_CL09             "Clear Counter 9  [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl09:switch", expire="1s,command=OFF" }
Switch ADAM6050_01_CL10             "Clear Counter 10 [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl10:switch", expire="1s,command=OFF" }
Switch ADAM6050_01_CL11             "Clear Counter 11 [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl11:switch", expire="1s,command=OFF" }

Hopefully this helps

1 Like

You could not tell me how to adapt it to your code.

for here:

modbus:tcp.slave1.connection=10.1.1.184
modbus:tcp.slave1.length=21
modbus:slave1.valuetype=bit
modbus:tcp.slave1.type=coil

convert to:

Bridge modbus:tcp:ADAM6050_01 [ host="10.1.1.184", port=502, id=1 ]
{
    // These correspond to input register numbers 00001 - 00012
    // documentation not clear for me, if I use discrete if always start by 0
    // and discrete means read only
    Bridge poller coilsClears [ start=0, length=21, refresh=500, type="coil" ]
    {
        Thing data cl00 [ readStart="0",  readValueType="bit", writeStart="0", writeValueType="bit", writeType="coil" ]
        Thing data cl01 [ readStart="1",  readValueType="bit" , writeStart="1", writeValueType="bit", writeType="coil" ]
     }
}

Switch ADAM6050_01_CL00             "light-1  [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl00:switch" }
Switch ADAM6050_01_CL01             "light-2  [%s]"   { channel="modbus:data:ADAM6050_01:coilsClears:cl01:switch" }

I’m working on the same problem, Modbus TCP with OpenHAB 2.
As I understod, there is only a “things”-file nessecary.

Is really no binding or other add-on nessecary?
The only binding I found is binding-modbus1 - 1.12.0 but i work with OH 2.3.0

Because my modbus is not working yet and I don’t know where to start to find the problem :wink:

Modus v2 binding is only included from OH 2.4 onwards

Download the modbus binding 2.4 from the source above (of this post). Create a thing file as mentioned in the documentation.

Post thing content and item content here and some hints about the device you use. Good if you post some register/adress documentations of the modbus device too. Maybe I can help you.

Thank you very much!
I updated to 2.4 (I found no link above, but in the internet ;-))
And I found then the modbus 2.4 binding.
And then, my Integer is on the sitemap… So I will manage to read the float number well… :slight_smile:
Thanks again!

Could someone please help me get from modbus1 to modbus2 binding…
I´m using a serial dongle, but I simply cant get the connection to work. The doc´s are NOT very helpfull (to be honest), and there is no example of a setting up an serial. And how to set the parameters dont relly make any sense to me. I guess one will have to know, to be able to understand…

This is my modbus1 cfg.:

poll=3000
serial.pollinterval="6000"
writemultipleregisters=true


serial.nilan_input_device.connection=/dev/ttyUSB-RS486:19200:8:even:1:rtu
serial.nilan_input_device.id=30
serial.nilan_input_device.start=0
serial.nilan_input_device.length=4
serial.nilan_input_device.type=input

serial.nilan_holding_device.connection=/dev/ttyUSB-RS486:19200:8:even:1:rtu
serial.nilan_holding_device.id=30
serial.nilan_holding_device.start=0
serial.nilan_holding_device.length=1
serial.nilan_holding_device.type=holding

Notice , I use symlinks for serial port. I cant chose symlinks in paperUI, so I have to create the .things file manually.

I don’t know the Serial-Connection.
I did it with TCP. For this i had to update my Openhab to version 2.4
And then, no cfg-File is neccesary.
I have only a things-file:

Bridge modbus:tcp:TwinCat [ host=“192.168.1.99”, port=502, id=1 ] {
Bridge poller holding [ start=0, length=26, refresh=1000, type=“holding” ] {
Thing data holding0000 [ readStart=“0”, readValueType=“float32_swap” ]
Thing data holding0002 [ readStart=“2”, readValueType=“float32_swap” ]
Thing data holding0004 [ readStart=“4”, readValueType=“float32_swap” ]
Thing data holding0006 [ readStart=“6”, readValueType=“float32_swap” ]
Thing data holding0008 [ readStart=“8”, readValueType=“float32_swap” ]
Thing data holding0010 [ readStart=“10”, readValueType=“float32_swap” ]
Thing data holding0012 [ readStart=“12”, readValueType=“float32_swap” ]
Thing data holding0014 [ readStart=“14”, readValueType=“float32_swap” ]
Thing data holding0016 [ readStart=“16”, readValueType=“float32_swap” ]
Thing data holding0018 [ readStart=“18”, readValueType=“float32_swap” ]
Thing data holding0020 [ readStart=“20”, readValueType=“float32_swap” ]
Thing data holding0022 [ readStart=“22”, readValueType=“float32_swap” ]
Thing data holding0024 [ readStart=“24”, readValueType=“float32_swap” ]
}
}

and a items-file with lines like this…

Number ModbusWert1 “Aussen Temperatur [%.1f °C]” { channel=“modbus:data:TwinCat:holding:holding0000:number” }
Number ModbusWert2 “Aussen Feuchte [%.0f %%]” { channel=“modbus:data:TwinCat:holding:holding0002:number” }
Number ModbusWert3 “Zimmer Temperatur [%.1f °C]” { channel=“modbus:data:TwinCat:holding:holding0004:number” }
Number ModbusWert4 “Zimmer Feuchte [%.0f %%]” { channel=“modbus:data:TwinCat:holding:holding0006:number” }
Number ModbusWert5 “Zimmer VOC [%.0f %%]” { channel=“modbus:data:TwinCat:holding:holding0008:number” }

and the sitemap contains for example lines like this:

      Frame label="Temperatur und Feuchte Aussen" {
            Text item=ModbusWert1       //Aussentemperatur
            Text item=ModbusWert2       //Aussenfeuchte

That’s fine, xxx.things file is probably easier to manage.

Okay, so you want a serial bridge Thing to represent your device

Bridge modbus:serial:myNilan [ port="ttyUSB-RS486", id=30, baud=19200, stopBits=1, parity="even", daaBits=8, encoding="rtu" ] {
   // here will go any pollers
}

Next you want to read some input data regularly, so you’ll need a poller bridge Thing to describe what and when

   Bridge poller inputRegisters [ start=0, length=4, refresh=6000, type="input" ] {
   // here will go data thing(s)
}

Then you’ll want a data Thing to describe how to handle the raw Modbus registers

Thing data input01 [ readStart=0, readValueType="uint16" ]

The data Thing will create channels that we can link to Items.

Putting it together -

Bridge modbus:serial:myNilan [ port="ttyUSB-RS486", id=30, baud=19200, stopBits=1, parity="even", dataBits=8, encoding="rtu" ] {
   Bridge poller inputRegisters [ start=0, length=4, refresh=6000, type="input" ] {
      Thing data inp00 [ readStart=0, readValueType="uint16" ]
      Thing data inp01 [ readStart=1, readValueType="uint16" ]
      // inp02, inp03 similar
   }
}

EDIT - serial Thing has an error, use stopBits=“1” with quotemarks.
MORE EDIT - use stopBits=“1.0” to have it neatly visible in PaperUI as well

myNilan, inputRegisters, inp00 are all names that we have chosen to suit ourselves

Linking an Item, using the channel selector :number (as opposed to :switch for example)

Number myItem "blah" { channel="modbus:data:myNilan:inputRegisters:inp00:number"

See how far you can get from there.
For your holding registers, you will want to add another poller under the same serial bridge, and add data things with write parameters as well as read.

Please tell us what you think is missing from the docs. I can see there is no serial bridge example, but it does follow the TCP type closely.

1 Like

I get an error in the Bridge settings (.things file).

This is the thing file:

Bridge modbus:serial:myNilan [ port="ttyUSB-RS486", id=30, baud=19200, stopBits=1, parity="even", dataBits=8, encoding="rtu" ] {
   // here will go any pollers
}

This is the error:

018-12-16 00:01:18.434 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'nilan.things'
==> /var/log/openhab2/events.log <==
2018-12-16 00:01:18.541 [hingStatusInfoChangedEvent] - 'modbus:serial:myNilan' changed from UNINITIALIZED to INITIALIZING
==> /var/log/openhab2/openhab.log <==
2018-12-16 00:01:18.542 [WARN ] [me.config.core.internal.ConfigMapper] - Could not set field value for field 'stopBits': Can not set java.lang.String field org.openhab.binding.modbus.internal.config.ModbusSerialConfiguration.stopBits to java.math.BigDecimal
java.lang.IllegalArgumentException: Can not set java.lang.String field org.openhab.binding.modbus.internal.config.ModbusSerialConfiguration.stopBits to java.math.BigDecimal
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) ~[?:?]
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) ~[?:?]
	at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) ~[?:?]
	at java.lang.reflect.Field.set(Field.java:764) ~[?:?]
	at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:523) ~[38:org.apache.commons.lang:2.6.0]
	at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:500) ~[38:org.apache.commons.lang:2.6.0]
	at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:560) ~[38:org.apache.commons.lang:2.6.0]
	at org.eclipse.smarthome.config.core.internal.ConfigMapper.as(ConfigMapper.java:102) [97:org.eclipse.smarthome.config.core:0.10.0.oh240M8]
	at org.eclipse.smarthome.config.core.Configuration.as(Configuration.java:85) [97:org.eclipse.smarthome.config.core:0.10.0.oh240M8]
	at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.getConfigAs(BaseThingHandler.java:274) [109:org.eclipse.smarthome.core.thing:0.10.0.oh240M8]
	at org.openhab.binding.modbus.internal.handler.ModbusSerialThingHandler.configure(ModbusSerialThingHandler.java:38) [274:org.openhab.binding.modbus:2.4.0.M8]
	at org.openhab.binding.modbus.internal.handler.AbstractModbusEndpointThingHandler.initialize(AbstractModbusEndpointThingHandler.java:65) [274:org.openhab.binding.modbus:2.4.0.M8]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240M8]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240M8]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]

==> /var/log/openhab2/events.log <==

2018-12-16 00:01:18.555 [hingStatusInfoChangedEvent] - 'modbus:serial:myNilan' changed from INITIALIZING to OFFLINE (CONFIGURATION_ERROR): Exception during initialization: port, baud, flowControlIn, flowControlOut, stopBits, parity, encoding all must be non-null! (ModbusConfigurationException)

Ahh found the error… stopBits was missing “”

1 Like

Yep, that’s in the documentation


I think it’s the possibility of 1.5 that makes that numeric parameter an oddball.

You´re right…
And thanks alot for all your help… This has given me alot more to go for now.

See how you get on with the writable registers. I think you’ll need
writeMultipleEvenWithSingleRegisterOrCoil
to reproduce your old setup.

Keep us posted on any docu suggestions. Modbus is odd, everyone’s setup is very different so examples are not always helpful, but a working setup at the end would be god to share here.

Thats my worse problem, cause I really know very little about modbus. My previous setup was a copy from the OpenHAB1/2 Nilan heatpump. And I really struggle to understand how things works…
This new modbus did not make things any better for my understanding :face_with_raised_eyebrow:

I can see from you help, I was actually on the right track regarding setting up the USB stick… What I was missing and doing wrong was the commas… And second, I was using full path to the device ie /dev/ttyUSB-RS486…
An example in the doc´s would be a great help to others, I would say.

Hmm… I believe I have some USB/symlinks problems here…
When I add an poller, I get an error:

2018-12-16 12:04:54.816 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/1 error: Modbus serial device ttyUSB-RS486 doesn't exist!. Connection SerialConnection@6295d1[portName=ttyUSB-RS486,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@354c92[portName=ttyUSB-RS486]
==> /var/log/openhab2/events.log <==
2018-12-16 12:04:54.818 [hingStatusInfoChangedEvent] - 'modbus:poller:myNilan:inputRegisters' changed from INITIALIZING to ONLINE
==> /var/log/openhab2/openhab.log <==
2018-12-16 12:04:54.820 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - re-connect reached max tries 1, throwing last error: Modbus serial device ttyUSB-RS486 doesn't exist!. Connection SerialConnection@6295d1[portName=ttyUSB-RS486,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@354c92[portName=ttyUSB-RS486]
2018-12-16 12:04:54.822 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection SerialConnection@6295d1[portName=ttyUSB-RS486,port=<null>] for endpoint ModbusSerialSlaveEndpoint@354c92[portName=ttyUSB-RS486]: Modbus serial device ttyUSB-RS486 doesn't exist!
2018-12-16 12:04:54.824 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Could not connect to endpoint ModbusSerialSlaveEndpoint@354c92[portName=ttyUSB-RS486] -- aborting request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@19a2231[slaveId=30,functionCode=READ_INPUT_REGISTERS,start=0,length=4,maxTries=3] [operation ID 10e406f6-337a-4da5-9d63-68296dfb0e90]
==> /var/log/openhab2/events.log <==
2018-12-16 12:04:54.831 [hingStatusInfoChangedEvent] - 'modbus:poller:myNilan:inputRegisters' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.io.transport.modbus.ModbusConnectionException: Error connecting to endpoint ModbusSerialSlaveEndpoint@354c92[portName=ttyUSB-RS486]
2018-12-16 12:04:54.874 [hingStatusInfoChangedEvent] - 'modbus:data:myNilan:inputRegisters:inp00' changed from UNINITIALIZED to INITIALIZING

I´m getting really tired of this USB/Linux stuff. :face_with_symbols_over_mouth:
With 2.3 setup and the old modbus, it was working rock steady!! (config showed in earlier msg). Then I added a new USB stick (WirelessMbus) and things went bananas… I had to create symlinks to get things working again…
Since then, I´ve struggled with the symlinks. First the Wireless Mbus stick wouldn´t connect. And now this RS486 stick is given a problem as well.
But my Zigbee and a z-wave stick´s are working just fine, just as well as my USB SSD.

This is really killing me!

Well at least we get a clear message!
I know nowt about symlinks. Might be help here