Modbus openHAB2 binding available for alpha testing

It may be that this is the programmed behavior of the device - “when off, interpret any non-100 incoming command as ‘restore last brightness’ regardless of value”.
Allowing a special case for instant 100/max.

EDIT - could instead be that command 1 is the special case, for restore last !

Sami and I are expecting untransformed ON to send value ‘1’ to the device.

@rossko57

Yes I think you are right, a physical short press on the light switch is equal to restore the light to its previous state.

Sure, makes sense.
It just seemed clumsy to read a “uint16” and write the same register as “int16”.
To save some user hair-pulling I’d say both types should be allowed for write even if they perform the exact same operation.
This is just cosmetics, though.

Makes me realise I don’t write numeric registers in my config!

1 Like

Hi Sami (@ssalonen)

From time to time I’ve see the following error logs

2018-09-19 18:30:06.951 [ERROR] [wimpi.modbus.io.ModbusTCPTransaction] - execute try 1/1 error: I/O exception: SocketException Connection reset. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@14799c0 (unit id 1 & transaction 23559). Address: /192.168.1.122:502

2018-09-19 18:30:06.954 [ERROR] [wimpi.modbus.io.ModbusTCPTransaction] - execute reached max tries 1, throwing last error: I/O exception: SocketException Connection reset. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@14799c0 (unit id 1 & transaction 23559). Address: /192.168.1.122:502

2018-09-19 18:30:06.957 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@e1bd71[slaveId=1,functionCode=READ_MULTIPLE_REGISTERS,start=75,length=7,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: SocketException Connection reset [operation ID 9bf31207-587d-4c1b-896a-7dbe7a80ec0a]

Do you have any idea if this is a problem of the Modfbus master (OH) or of the Modbus slave (heater)?

I/O exception: SocketException Connection reset

Sounds for me like a TCP/IP socket problem on the OH side.

Best regards
Raphael

To be honest, not sure. You can find more information here : https://stackoverflow.com/questions/62929/java-net-socketexception-connection-reset/4300803

Wireshark capture at the time of error might give more details…

Hi Sami (@ssalonen)

Thanks for the hint.

Best regards
Raphael

1 Like

Hi,

I am experiencing a strange problem with the serial stuff. I’ve tested a snapshot of the new binding a couple of months ago and the performance was great. Right on par with the legacy binding, even with many slaves and 50~ modbus transactions a second.

Long story short: today I’ve installed openhab on a new machine (Debian Stretch, Oracle Java 8, openhab2 snapshot and I’ve also tried testing and stable) and things don’t seem to work well anymore (literally). I am getting extremely high cpu load (approaching 100%) with the thing configuration below. I’ve tried this exact same .thing file a couple of months ago and the cpu load was negligible at best… am I missing something?

Thx for your help,
Max

Bridge modbus:serial:hut22 [ port="/dev/ttyUSB0", baud=38400, id=22, stopBits="1.0", parity="none",dataBits=8, echo=false, encoding="rtu", flowControlIn="none", flowControlOut="none", receiveTimeoutMillis=1000, timeBetweenTransactionsMillis=100 ] 
{ 
 
        Bridge poller coils [ start=0, length=99, refresh=100, type="coil" ] 
        { 
                Thing data out0 [ readStart="0", readValueType="bit", writeStart="0", writeValueType="bit", writeType="coil" ] 
                Thing data out1 [ readStart="1", readValueType="bit", writeStart="1", writeValueType="bit", writeType="coil" ] 
                Thing data out2 [ readStart="2", readValueType="bit", writeStart="2", writeValueType="bit", writeType="coil" ] 
                Thing data out3 [ readStart="3", readValueType="bit", writeStart="3", writeValueType="bit", writeType="coil" ] 
                Thing data out4 [ readStart="4", readValueType="bit", writeStart="4", writeValueType="bit", writeType="coil" ] 
                Thing data out5 [ readStart="5", readValueType="bit", writeStart="5", writeValueType="bit", writeType="coil" ] 
                Thing data out6 [ readStart="6", readValueType="bit", writeStart="6", writeValueType="bit", writeType="coil" ] 
                Thing data out7 [ readStart="7", readValueType="bit", writeStart="7", writeValueType="bit", writeType="coil" ] 
                Thing data out8 [ readStart="8", readValueType="bit", writeStart="8", writeValueType="bit", writeType="coil" ] 
                Thing data out9 [ readStart="9", readValueType="bit", writeStart="9", writeValueType="bit", writeType="coil" ] 
                Thing data out10 [ readStart="10", readValueType="bit", writeStart="10", writeValueType="bit", writeType="coil" ] 
                Thing data out11 [ readStart="11", readValueType="bit", writeStart="11", writeValueType="bit", writeType="coil" ] 
                Thing data out12 [ readStart="12", readValueType="bit", writeStart="12", writeValueType="bit", writeType="coil" ] 
                Thing data out13 [ readStart="13", readValueType="bit", writeStart="13", writeValueType="bit", writeType="coil" ] 
                Thing data out14 [ readStart="14", readValueType="bit", writeStart="14", writeValueType="bit", writeType="coil" ] 
                Thing data out15 [ readStart="15", readValueType="bit", writeStart="15", writeValueType="bit", writeType="coil" ] 
                 
                Thing data spush0 [ readStart="16", readValueType="bit", writeStart="16", writeValueType="bit", writeType="coil" ] 
                Thing data spush1 [ readStart="17", readValueType="bit", writeStart="17", writeValueType="bit", writeType="coil" ] 
                Thing data spush2 [ readStart="18", readValueType="bit", writeStart="18", writeValueType="bit", writeType="coil" ] 
                Thing data spush3 [ readStart="19", readValueType="bit", writeStart="19", writeValueType="bit", writeType="coil" ] 
                Thing data spush4 [ readStart="20", readValueType="bit", writeStart="20", writeValueType="bit", writeType="coil" ] 
                Thing data spush5 [ readStart="21", readValueType="bit", writeStart="21", writeValueType="bit", writeType="coil" ] 
                Thing data spush6 [ readStart="22", readValueType="bit", writeStart="22", writeValueType="bit", writeType="coil" ] 
                Thing data spush7 [ readStart="23", readValueType="bit", writeStart="23", writeValueType="bit", writeType="coil" ] 
                Thing data spush8 [ readStart="24", readValueType="bit", writeStart="24", writeValueType="bit", writeType="coil" ] 
                Thing data spush9 [ readStart="25", readValueType="bit", writeStart="25", writeValueType="bit", writeType="coil" ] 
                Thing data spush10 [ readStart="26", readValueType="bit", writeStart="26", writeValueType="bit", writeType="coil" ] 
                Thing data spush11 [ readStart="27", readValueType="bit", writeStart="27", writeValueType="bit", writeType="coil" ] 
                Thing data spush12 [ readStart="28", readValueType="bit", writeStart="28", writeValueType="bit", writeType="coil" ] 
                Thing data spush13 [ readStart="29", readValueType="bit", writeStart="29", writeValueType="bit", writeType="coil" ] 
                Thing data spush14 [ readStart="30", readValueType="bit", writeStart="30", writeValueType="bit", writeType="coil" ] 
                Thing data spush15 [ readStart="31", readValueType="bit", writeStart="31", writeValueType="bit", writeType="coil" ] 
                 
                Thing data lpush0 [ readStart="32", readValueType="bit", writeStart="32", writeValueType="bit", writeType="coil" ] 
                Thing data lpush1 [ readStart="33", readValueType="bit", writeStart="33", writeValueType="bit", writeType="coil" ] 
                Thing data lpush2 [ readStart="34", readValueType="bit", writeStart="34", writeValueType="bit", writeType="coil" ] 
                Thing data lpush3 [ readStart="35", readValueType="bit", writeStart="35", writeValueType="bit", writeType="coil" ] 
                Thing data lpush4 [ readStart="36", readValueType="bit", writeStart="36", writeValueType="bit", writeType="coil" ] 
                Thing data lpush5 [ readStart="37", readValueType="bit", writeStart="37", writeValueType="bit", writeType="coil" ] 
                Thing data lpush6 [ readStart="38", readValueType="bit", writeStart="38", writeValueType="bit", writeType="coil" ] 
                Thing data lpush7 [ readStart="39", readValueType="bit", writeStart="39", writeValueType="bit", writeType="coil" ] 
                Thing data lpush8 [ readStart="40", readValueType="bit", writeStart="40", writeValueType="bit", writeType="coil" ] 
                Thing data lpush9 [ readStart="41", readValueType="bit", writeStart="41", writeValueType="bit", writeType="coil" ] 
                Thing data lpush10 [ readStart="42", readValueType="bit", writeStart="42", writeValueType="bit", writeType="coil" ] 
                Thing data lpush11 [ readStart="43", readValueType="bit", writeStart="43", writeValueType="bit", writeType="coil" ] 
                Thing data lpush12 [ readStart="44", readValueType="bit", writeStart="44", writeValueType="bit", writeType="coil" ] 
                Thing data lpush13 [ readStart="45", readValueType="bit", writeStart="45", writeValueType="bit", writeType="coil" ] 
                Thing data lpush14 [ readStart="46", readValueType="bit", writeStart="46", writeValueType="bit", writeType="coil" ] 
                Thing data lpush15 [ readStart="47", readValueType="bit", writeStart="47", writeValueType="bit", writeType="coil" ] 
                 
                Thing data rising0 [ readStart="48", readValueType="bit", writeStart="48", writeValueType="bit", writeType="coil" ] 
                Thing data rising1 [ readStart="49", readValueType="bit", writeStart="49", writeValueType="bit", writeType="coil" ] 
                Thing data rising2 [ readStart="50", readValueType="bit", writeStart="50", writeValueType="bit", writeType="coil" ] 
                Thing data rising3 [ readStart="51", readValueType="bit", writeStart="51", writeValueType="bit", writeType="coil" ] 
                Thing data rising4 [ readStart="52", readValueType="bit", writeStart="52", writeValueType="bit", writeType="coil" ] 
                Thing data rising5 [ readStart="53", readValueType="bit", writeStart="53", writeValueType="bit", writeType="coil" ] 
                Thing data rising6 [ readStart="54", readValueType="bit", writeStart="54", writeValueType="bit", writeType="coil" ] 
                Thing data rising7 [ readStart="55", readValueType="bit", writeStart="55", writeValueType="bit", writeType="coil" ] 
                Thing data rising8 [ readStart="56", readValueType="bit", writeStart="56", writeValueType="bit", writeType="coil" ] 
                Thing data rising9 [ readStart="57", readValueType="bit", writeStart="57", writeValueType="bit", writeType="coil" ] 
                Thing data rising10 [ readStart="58", readValueType="bit", writeStart="58", writeValueType="bit", writeType="coil" ] 
                Thing data rising11 [ readStart="59", readValueType="bit", writeStart="59", writeValueType="bit", writeType="coil" ] 
                Thing data rising12 [ readStart="60", readValueType="bit", writeStart="60", writeValueType="bit", writeType="coil" ] 
                Thing data rising13 [ readStart="61", readValueType="bit", writeStart="61", writeValueType="bit", writeType="coil" ] 
                Thing data rising14 [ readStart="62", readValueType="bit", writeStart="62", writeValueType="bit", writeType="coil" ] 
                Thing data rising15 [ readStart="63", readValueType="bit", writeStart="63", writeValueType="bit", writeType="coil" ] 
                 
                Thing data falling0 [ readStart="64", readValueType="bit", writeStart="64", writeValueType="bit", writeType="coil" ] 
                Thing data falling1 [ readStart="65", readValueType="bit", writeStart="65", writeValueType="bit", writeType="coil" ] 
                Thing data falling2 [ readStart="66", readValueType="bit", writeStart="66", writeValueType="bit", writeType="coil" ] 
                Thing data falling3 [ readStart="67", readValueType="bit", writeStart="67", writeValueType="bit", writeType="coil" ] 
                Thing data falling4 [ readStart="68", readValueType="bit", writeStart="68", writeValueType="bit", writeType="coil" ] 
                Thing data falling5 [ readStart="69", readValueType="bit", writeStart="69", writeValueType="bit", writeType="coil" ] 
                Thing data falling6 [ readStart="70", readValueType="bit", writeStart="70", writeValueType="bit", writeType="coil" ] 
                Thing data falling7 [ readStart="71", readValueType="bit", writeStart="71", writeValueType="bit", writeType="coil" ] 
                Thing data falling8 [ readStart="72", readValueType="bit", writeStart="72", writeValueType="bit", writeType="coil" ] 
                Thing data falling9 [ readStart="73", readValueType="bit", writeStart="73", writeValueType="bit", writeType="coil" ] 
                Thing data falling10 [ readStart="74", readValueType="bit", writeStart="74", writeValueType="bit", writeType="coil" ] 
                Thing data falling11 [ readStart="75", readValueType="bit", writeStart="75", writeValueType="bit", writeType="coil" ] 
                Thing data falling12 [ readStart="76", readValueType="bit", writeStart="76", writeValueType="bit", writeType="coil" ] 
                Thing data falling13 [ readStart="77", readValueType="bit", writeStart="77", writeValueType="bit", writeType="coil" ] 
                Thing data falling14 [ readStart="78", readValueType="bit", writeStart="78", writeValueType="bit", writeType="coil" ] 
                Thing data falling15 [ readStart="79", readValueType="bit", writeStart="79", writeValueType="bit", writeType="coil" ] 
                         
                Thing data in0 [ readStart="80", readValueType="bit", writeStart="80", writeValueType="bit", writeType="coil" ] 
                Thing data in1 [ readStart="81", readValueType="bit", writeStart="81", writeValueType="bit", writeType="coil" ] 
                Thing data in2 [ readStart="82", readValueType="bit", writeStart="82", writeValueType="bit", writeType="coil" ] 
                Thing data in3 [ readStart="83", readValueType="bit", writeStart="83", writeValueType="bit", writeType="coil" ] 
                Thing data in4 [ readStart="84", readValueType="bit", writeStart="84", writeValueType="bit", writeType="coil" ] 
                Thing data in5 [ readStart="85", readValueType="bit", writeStart="85", writeValueType="bit", writeType="coil" ] 
                Thing data in6 [ readStart="86", readValueType="bit", writeStart="86", writeValueType="bit", writeType="coil" ] 
                Thing data in7 [ readStart="87", readValueType="bit", writeStart="87", writeValueType="bit", writeType="coil" ] 
                Thing data in8 [ readStart="88", readValueType="bit", writeStart="88", writeValueType="bit", writeType="coil" ] 
                Thing data in9 [ readStart="89", readValueType="bit", writeStart="89", writeValueType="bit", writeType="coil" ] 
                Thing data in10 [ readStart="90", readValueType="bit", writeStart="90", writeValueType="bit", writeType="coil" ] 
                Thing data in11 [ readStart="91", readValueType="bit", writeStart="91", writeValueType="bit", writeType="coil" ] 
                Thing data in12 [ readStart="92", readValueType="bit", writeStart="92", writeValueType="bit", writeType="coil" ] 
                Thing data in13 [ readStart="93", readValueType="bit", writeStart="93", writeValueType="bit", writeType="coil" ] 
                Thing data in14 [ readStart="94", readValueType="bit", writeStart="94", writeValueType="bit", writeType="coil" ] 
                Thing data in15 [ readStart="95", readValueType="bit", writeStart="95", writeValueType="bit", writeType="coil" ] 
                 
                         
                         
        } 
         
        Bridge poller sensor    [ start=52, length=1, refresh=2000, type="holding" ] 
        { 
                Thing data voltage              [ readStart="52", readValueType="uint16", readTransform="JS(divide1000.js)"     ] 
         
        } 
         
}

Hi

Perhaps try out with openhab 2.3 stable? If you still see issues, we can try to profile the cpu usage.

The changes to the binding are pretty minor and I don’t understand how they would cause any performance degradation.

1 Like

Hi Sami,

I’ve tried Openhab Stable 2.3.0 and installed modbus transport and the binding manually (took the artefacts from here and here). The problem persists.

1 Like

I will try replicate the issue here first, by replacing the serial with tcp…

Could you please share the items as well?

If you feel adventerous, you can try out YourKit java profiler to see where the bottleneck might be…

Switch  test0   "0"             {channel="modbus:data:hut22:coils:out0:switch"} 
Switch  test1   "1"             {channel="modbus:data:hut22:coils:out1:switch"} 
Switch  test2   "2"             {channel="modbus:data:hut22:coils:out2:switch"} 
Switch  test3   "3"             {channel="modbus:data:hut22:coils:out3:switch"} 

Number  22voltage               "Spannung 22 [%2.2f V]"         {channel="modbus:data:hut22:sensor:voltage:number"}

However, even without any items defined the problem is there.

1 Like

Btw do you have arm architecture? I was wondering whether zulu java would be better for you? Any way, I believe that’s the recommended java with openhab

Nope. x86-64 (Intel N3050). That box is just for openhab, so rather beefy. :stuck_out_tongue:

I’ll try zulu anyway.

Good to hear this, should make it easier to test on my side…

Btw: no difference with zulu.

1 Like

Hi,

I am trying to read the input register show in the attached image. The line is marked in green.
I have tried everything but i can’t get the values read.

My things file looks like this

Bridge modbus:serial:wavin [ port="/dev/ttyUSB0", baud=38400, stopBits="1.0", parity="none", dataBits=8, encoding="rtu" ] { 

        Bridge poller input [ start=4000, length=5, refresh=300, type="input" ] { 
                
                Thing data ARC1 [ readStart="4000", readValueType="uint16" ] 
         
        } 
}

Does anyone knows what i am doing wrong here?

Best regards
Henrik

This thread has become very long and fragmented; unless discussing binding development, it’s probably better to address individual problems in your own new post / thread.

You’ll have to give us a bit more than “doesn’t read”. What’s in the logs? What does a sample Item look like?

Off the top of my head, you’ve set up a poller to read Input registers starting at decimal 4000.
The datasheet for your mystery modbus device says its registers are in the 4000 hex range. You’l want to use addresses looking more like 16403 in your Thing definitions.

I am sorry if i jacked the thread @rossko57.
I just saw a bunch of other people asked a whole lot of questions so i guessed it will be okay. But i will start a new thread then.

To answer your questions then i does not work seeting the address to 16403.

The log says

2018-10-03 19:13:50.984 [TRACE] [et.wimpi.modbus.net.SerialConnection] - Got Port Identifier
2018-10-03 19:13:50.998 [TRACE] [et.wimpi.modbus.net.SerialConnection] - Got Serial Port
2018-10-03 19:13:51.002 [TRACE] [et.wimpi.modbus.net.SerialConnection] - i/o Streams prepared
2018-10-03 19:13:51.008 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Sent: 01 04 40 13 00 01 d5 cf
2018-10-03 19:13:52.510 [TRACE] [t.wimpi.modbus.io.ModbusRTUTransport] - Managed to read at least one byte
2018-10-03 19:13:52.512 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 04 40 13 00 01 d5 cf
2018-10-03 19:13:52.512 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2018-10-03 19:13:52.513 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/1 error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@33a6b6 (unit id 1 & transaction 483). Serial parameters: SerialParameters@1e85831[portName=/dev/ttyUSB0,baudRate=38400,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2018-10-03 19:13:52.514 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 1, throwing last error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@33a6b6 (unit id 1 & transaction 483). Serial parameters: SerialParameters@1e85831[portName=/dev/ttyUSB0,baudRate=38400,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2018-10-03 19:13:52.515 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1d612bb[slaveId=1,functionCode=READ_INPUT_REGISTERS,start=16403,length=1,maxTries=3]). Aborting. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: IOException Error reading response (EOF) [operation ID 36c6471d-66e8-4843-a316-2b5c45f52756]
2018-10-03 19:13:52.525 [DEBUG] [handler.ModbusPollerThingHandlerImpl] - Thing modbus:poller:wavin:input received error ModbusSlaveIOException(cause=ModbusIOException, EOF=false, message='I/O exception: IOException Error reading response (EOF)', cause2=null) for request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1d612bb[slaveId=1,functionCode=READ_INPUT_REGISTERS,start=16403,length=1,maxTries=3]
2018-10-03 19:13:52.526 [ERROR] [odbus.handler.ModbusDataThingHandler] - Thing modbus:data:wavin:input:ARC1 'Modbus data' had ModbusSlaveIOExceptionImpl error on read: ModbusSlaveIOException(cause=ModbusIOException, EOF=false, message='I/O exception: IOException Error reading response (EOF)', cause2=null)
2018-10-03 19:13:52.530 [DEBUG] [odbus.handler.ModbusDataThingHandler] - bridgeStatusChanged for modbus:data:wavin:input:ARC1. Reseting handler
2018-10-03 19:13:52.531 [TRACE] [odbus.handler.ModbusDataThingHandler] - initialize() of thing modbus:data:wavin:input:ARC1 'Modbus data' starting
2018-10-03 19:13:52.533 [TRACE] [odbus.handler.ModbusDataThingHandler] - initialize() of thing modbus:data:wavin:input:ARC1 'Modbus data' finished

The items file

Number  warc1 	"[%f]"	{channel="modbus:data:wavin:input:ARC1:number"}

No sorry needed - it’s not about hijacking, it’s about your difficulty getting buried among a hundred unrelated problems and labelled as being about alpha testing.

Looks like Modbus binding simply cannot connect to your device - check serial parameters etc. Are you able to test with some other modbus tool from your OH host hardware, or have any twinkly LEDs to help see activity?

@rossko57 I know, the new thread is started tho.

It should not be the connection.
I have used an Python script that can read the sucessufully. I have also used an other plugin for openhab that can read the temperatures but it is not possible to set the tempereature.
So i wanted to test with an universal modbus binding and create an simple connection, there is easy to maintain.