Modbus issues - values can be read but log full of errors

Many Thanks. It is aktivated. I did it also with UDP ON, it changed noting

grafik

I will give that a try this evening.
Thanks a lot

I had a look at the stripped things and items setup in the first post.
There is no closing bracket, may be you did not copy everything.

Bridge modbus:tcp:tripower "SMA Sunny Tripower 9000TL-20"  
[ host="192.168.100.48", port=502, id=3, reconnectAfterMillis=6000 ] 
{
	Bridge poller devicedaten_30053 "Geraete Spezifikation" 
	[ start=30053, length=4, refresh=60000, type="input" ] 
	{
        Thing data sma_type_30053 "SMA Wechselrichter Type" 
		[ readStart="30053", readValueType="uint32" ]
    }

    Bridge poller input_30769_114 "TP_Input_30769_114" 
	[ start=30773, length=114, refresh=2000, type="input" ] 
	{
        Thing data 30773_2 "TP_30773_2" 
		[ readStart="30773", readValueType="int32"]
        Thing data 30775_2 "TP_30775_2" 
		[ readStart="30775", readValueType="int32"]
		Thing data 30839_2 "TP_30839_2" 
		[ readStart="30839", readValueType="uint32"]
	}

} <-this bracket is missing !!

Apart from that I strongly recommend to follow the advice given by rossko57

For a start do not try to read multiple registers but just a single register.

Bridge modbus:tcp:tripower "SMA Sunny Tripower 9000TL-20"  
[ host="192.168.100.48", port=502, id=3, reconnectAfterMillis=6000 ] 
{
    Bridge poller input_30775_4 "TP_Input_30775_4" 
	[ start=30775, length=4, refresh=60000, type="input" ] 
	{
        Thing data 30775_4 "TP_30775_4" 
		[ readStart="30775", readValueType="int64"]
	}
}

Note that the poller length= 4 and the readValueType=“int64”
This is due to the fact that some SMA converters “fragmentate” tcp messages.
This is an SMA error, but has been addressed in OPENHAB 3.

Give it a try and report back what error messages are left using this very basic setup.
Good luck !

2 Likes

OK,

I changed things file to this:

Bridge modbus:tcp:tripower [ host="192.168.100.48", port=502, id=3, connectMaxTries=3] {

        Bridge poller input_30775_4 "SMA_Power_input_gesamt" [ start=30775, length=4, refresh=5000, type="input" ] {

                Thing data 30775_4 [ readStart="30775", readValueType="int32"]

        }

}

this is the error message:

2022-03-11 22:34:24.730 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'sma.things'
2022-03-11 22:34:38.710 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: connect timed out. Connection TCPMasterConnection@5cbf5ab9[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@6da9c64e[address=192.168.100.48,port=502]
2022-03-11 22:35:33.456 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: connect timed out. Connection TCPMasterConnection@3678a657[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@6da9c64e[address=192.168.100.48,port=502]
2022-03-11 22:36:03.916 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: connect timed out. Connection TCPMasterConnection@480b2713[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@6da9c64e[address=192.168.100.48,port=502]
2022-03-11 22:36:13.984 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 2/3 error: connect timed out. Connection TCPMasterConnection@480b2713[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@6da9c64e[address=192.168.100.48,port=502]
2022-03-11 22:36:24.054 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 3/3 error: connect timed out. Connection TCPMasterConnection@480b2713[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@6da9c64e[address=192.168.100.48,port=502]
2022-03-11 22:36:24.055 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - re-connect reached max tries 3, throwing last error: connect timed out. Connection TCPMasterConnection@480b2713[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@6da9c64e[address=192.168.100.48,port=502]
2022-03-11 22:36:24.055 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection TCPMasterConnection@480b2713[socket=Socket[unconnected]] for endpoint ModbusTCPSlaveEndpoint@6da9c64e[address=192.168.100.48,port=502]: connect timed out
2022-03-11 22:36:24.055 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Could not connect to endpoint ModbusTCPSlaveEndpoint@6da9c64e[address=192.168.100.48,port=502] -- aborting request ModbusReadRequestBlueprint@1653460b[slaveId=3,functionCode=READ_INPUT_REGISTERS,start=30775,length=4,maxTries=3] [operation ID 31df311a-65ba-4f9b-aa8a-6d4ab2cc24a1]
2022-03-11 22:36:39.066 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: connect timed out. Connection TCPMasterConnection@4903bc33[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@6da9c64e[address=192.168.100.48,port=502]

Item is showing a value. Even this is quite strange but I saw this earlier:
grafik

This is something I am catching with a rule.

ah, btw:
I had to shutdown my inverter first. I tried to connect with asimplymodbus to connect which was working normally but after lots of testing this did not work. So I shutdown inverter and after reboot I could connect again

While SMA can be picky about configuring addresses etc., you are getting a bunch of errors that other people do not see. What is more, it all seems a bit intermittent.
Smells strongly of flaky network somewhere.

I had (and still have) a similar issue with solar edge inverter. (see last post of Solaredge inverter via Modbus TCP 2 - Tutorials & Examples - openHAB Community)

At the beginning, my things even went offline and I had hundred of errors in the log. The cause seems to be because I have to read two different register seperatly (Production and use). Setting the “Time Between Transactions” in the Modbus TCP Slave to 250ms reduced my errors a lot, but I still get some which I just ignore for now.

I miss my Kostal Inverter which had a great OH-Binding without using Modbus. (And a much better local Webinterface)

The negative value indicates that the investor is not producing power at the moment.
If length= 4 you will receive 8 bytes → 0x80000000 which is -2147483648
If length= 4 you will receive 4 bytes → 0x8000. which is -32768

I use following Read Transform function to transform negative values to zero

JS(TransferCurrentPower.js)
(function(i) {
	return Math.max(0,i);
})(input)
1 Like

Do you have a static IP address for your inverter ?
If not, switching off and on the inverter may result in a IP-address which different from the one you specified in your things file.
This could explain that you sometimes nothing is received.

You can use SUNNY EXPLORER to check

  • its MAC address: SUNNY EXPLORER > Settings > Type Label > MAC address

  • its current IP-Address: SUNNY EXPLORER > Settings > System communications > IP address

With this information you can create a static IP address in your Router.

2022-03-11 22:34:38.710 [ERROR] connect try 1/3 error: connect timed out.
second attempt was succesful

2022-03-11 22:35:33.456 [ERROR] connect try 1/3 error: connect timed out.
second attempt was succesful

2022-03-11 22:36:03.916 [ERROR] connect try 1/3 error: connect timed out.
2022-03-11 22:36:13.984 [ERROR] connect try 2/3 error: connect timed out.
2022-03-11 22:36:24.054 [ERROR] connect try 3/3 error: connect timed out.
no successful attempts, connection time out

I see no other way forward than capturing the TCP-IP traffic on your network.
Are you familiar with Wireshark ?

IP is correct in settings of the inverter (checked with sunny Explorer) and My Router is giving this device always the same IP (defined in settings)

But thanks anyway

One thing I saw several time: if i am using sunny explorer and do not use a save configuration it shows two different IP Addresses .41 and .48
Connection with Sunny Explorer is only possible with xxx.xxx.xxx.48
This is also the one I use for Modbus when I receive values. 41 is not working, already tested.

UPDATE:
I guess xxx.xxx.xxx.41 is the Smart Meter …

Thanks for this, I wrote an rule for that … you way is for sure the better one

Another option to proceed is the use of a Modbus Master Simulator.
I have been using the Radzio! Modbus Master Simulator.

[Modbus Master Simulator]

Note:
I am NOT suggesting that your problems are caused by OPENHAB.
I have been using the Radzio! Modbus Master Simulator to investigate the “lost byte problem”.
It helped me to find out that the “lost byte problem” was caused by SMA.

Feel free to contact me for further investigation !

1 Like

If I recall, the SMA didn’t quite follow the rules on TCP fragmentation. This might cause something in the middle of the network to mess up.

@Homer-Sim situation is unusual - once you set the minimum poll length 4, no-one else seems to suffer timeouts? I wonder if the router/switch might be fumbling the fragmented transfers, where most just pass it along as-is.

I tried that


I can not see an error

I tried it a second and third timer to connect.
Right after clicking connect button this message appears and then it disappears after lets say a second.

That’s behaving the same as openHAB, then. Are you running Radzio on the same host system?

No, Radzio had been executed from my Laptop and OH is on a Server

This is the status bar after a little while staying connected’
grafik

Did all 15 errors appear while the “Modbus message timeout” was there ?

Did you see the “Modbus message timeout” again while staying connected ?

As I checked it again, the error messages only counting while error message is present. After disappearing I did not see it again and error counter is unchanged

To make sure I do understand it right can you confirm following:

  • After you connect, the “Modbus message timeout” message appears for about 1 second.

  • if you then leave it running, no more “Modbus message timeout” messages appear and the error count does not change.

  • If you then disconnect and without making any change to the settings connect again,
    the “Modbus message timeout” message appears again for about 1 second.

In short, every time you disconnect and connect again the “Modbus message timeout” message appears.

Yes, you are right.
In even shorter, every time I connect the message appears