Reading data from Huawei inverter SUN 2000 (3KTL-10KTL) via modbus TCP and RTU

Great, thanks a lot!
I thought it may be some change, but I got no error message that lead me anywhere

I tried with settings from @splatch’s post like

port=502, id=2,
rtuEncoded=false,
connectMaxTries=-1, 
timeBetweenReconnectMillis=10000, 
connectTimeoutMillis=10000, 
reconnectAfterMillis=-1, 
timeBetweenTransactionsMillis=250, 
afterConnectionDelayMillis=2000,  
enableDiscovery=false 

in OH 3.3.0.M4
but it gives me more of the

Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint

warnings and errors.
Any suggestions?

PR against addons is not yet accepted, hence I am not sure if afterConnectionDelayMillis option is effective for you. Also, looking at the error, you have try 1 out of 3, try without retries.

Hi,

I got a question on the configuration. I did the Modbus TCP Slave setup through the GUI using 3.3.0-M4 where is does not allow for the following “-1” settings:

connectMaxTries=-1,
reconnectAfterMillis=-1,

The GUI says for connectMaxTries:

* Maximum Connection Tries

How many times we try to establish the connection. Should be at least *1*.

and for reconnectAfterMillis:

* Reconnect Again After

The connection is kept open at least the time specified here. Value of zero means that connection is disconnected after every MODBUS transaction. In milliseconds.

Also the new parameter afterConnectionDelayMillis is not shown on the GUI yet accepted when added through the Code window. Is the new code not active yet in 3.3.0-M4?

Thanks

Well I have more tries if you mean that:

[ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 3 failed when executing request (ModbusReadRequestBlueprint

I think these also for me do not work properly, yet.

connectMaxTries=-1,
reconnectAfterMillis=-1,

Can you keep us update if there is a release or snapshop where it should work?

What is the question?

@splatch referring to your tcp thing configuration: I see it has been configured in MainUI. How did you manage to configure those -1 parameters there? MainUI should disallow even entering those invalid values

@Andreas_Pircher what is the error? The log line seems to be incomplete and missing the error reason

I use own config based on XML which does not validate parameters very strictly (min/max declared in thing config descriptor). For clarity I just copied what main ui shows.

What I been looking for was finding a way to make infinite reconnect attempts. Reconnect delay is anyhow related to space between operations.

Hi @ssalonen & @splatch,

you cut my question away. The question is what are the recommended connection parameters for the Modbus TCP Slave?

I just upgraded to the new milestone release 3.3.0-M5. That one comes with enhancement #12642 which enables the afterConnectionDelayMillis parameter in the GUI. It work reasonable well now, thanks! This is the configuration I’m using now:

UID: modbus:tcp:5b0337a743
label: Modbus TCP Slave WR1
thingTypeUID: modbus:tcp
configuration:
  rtuEncoded: false
  connectMaxTries: 1
  reconnectAfterMillis: 60000
  timeBetweenTransactionsMillis: 500
  port: 502
  timeBetweenReconnectMillis: 3000
  connectTimeoutMillis: 10000
  host: 192.168.178.82
  afterConnectionDelayMillis: 2000
  id: 1
  enableDiscovery: false

I still see 3 scenarios happening, 2 recovering and 1 failing:

022-05-08 08:45:11.924 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=37000, length=70, maxTries=3]). Will try again soon. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: SocketTimeoutException Read timed out [operation ID a44c09a9-9672-4c99-8f6e-17b62fee9f78]
2022-05-08 09:50:07.225 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=37100, length=39, maxTries=3]). Will try again soon. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: SocketTimeoutException Read timed out [operation ID bc69f5d7-2a16-49f6-8e00-ab28b7f13ce9]
2022-05-08 09:50:09.232 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=37100, length=39, maxTries=3]). Will try again soon. The response did not match the request. Resetting the connection. Error details: org.openhab.core.io.transport.modbus.exception.ModbusUnexpectedTransactionIdException Transaction id of request (728) does not equal response (727). Slave response is invalid. [operation ID bc69f5d7-2a16-49f6-8e00-ab28b7f13ce9]
2022-05-08 09:10:06.605 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=32016, length=100, maxTries=3]). Will try again soon. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: SocketTimeoutException Read timed out [operation ID 4d227069-bc15-4e25-a47a-25791b664d78]
2022-05-08 09:10:08.622 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=32016, length=100, maxTries=3]). Will try again soon. Error was: net.wimpi.modbus.ModbusSlaveException Error Code = 6 [operation ID 4d227069-bc15-4e25-a47a-25791b664d78]
2022-05-08 09:10:09.124 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=32016, length=100, maxTries=3]). Aborting. The response did not match the request. Resetting the connection. Error details: org.openhab.core.io.transport.modbus.exception.ModbusUnexpectedTransactionIdException Transaction id of request (513) does not equal response (511). Slave response is invalid. [operation ID 4d227069-bc15-4e25-a47a-25791b664d78]

BTW, I’m using 2 Modbus TCP Slaves, one for each inverter in a cascade configuration with a single SDongle - so same IP, but different ModbusIDs.
4 Modbus Pollers (3+1) are accessing the 2 Salves in 1min resolution (refresh: 60000). The SDongle is connected over WLAN to my home network.

Please share your setup details for further configuration optimization.

Thanks

1 Like

In my case I tested it with two+two system. I am not sure how reliable SDongle is in your case. In theory its single rtu lane, but who knows what kind of weird optimizations their firmware is trying to do…

Please disable retry on the pollers, if they fail next poll cycle will bring you data anyway. I observed that retrying had rather a bad effect on the stability of these dongles.

I upgraded to 3.3.0-M5 an set the Bridge config

rtuEncoded=false, //default: false
connectMaxTries=1, //How many times we try to establish the connection. Should be at least 1.
timeBetweenReconnectMillis=3000, //How long to wait to before trying to establish a new connection after the previous one has been disconnected. In milliseconds.
connectTimeoutMillis=10000, //The maximum time that is waited when establishing the connection. Value of zero means that system/OS default is respected. In milliseconds.
reconnectAfterMillis=10000, //The connection is kept open at least the time specified here. Value of zero means that connection is disconnected after every MODBUS transaction. In milliseconds.
timeBetweenTransactionsMillis=500, //How long to delay we must have at minimum between two consecutive MODBUS transactions. In milliseconds.
enableDiscovery=false, //Enable auto-discovery feature. Effective only if a supporting extension has been installed.
afterConnectionDelayMillis=2000  // new parameter available in OH 3.3
.......
Bridge poller slavepowermeter [ start=**37113**, length=2, refresh=2000, type="holding", maxTries=1 ]{
.....
Bridge poller slave103bholding [ start=**32010**, length=1, refresh=10000, type="holding", maxTries=1 ]{   

I get these errors now:

2022-05-08 16:57:15.776 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 1 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=32010, length=1, maxTries=1]). Aborting. Error w w: net.wimpi.modbus.ModbusSlaveException Error Code = 6 [operation ID be37bf86-04bd-4674-9a47-f0db89ff5981]
as: net.wimpi.modbus.ModbusSlaveException Error Code = 6 [operation ID d27f7fa7-6906-498b-952b-f16579b0df70] re
2022-05-08 16:57:16.285 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 1 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=32009, length=1, maxTries=1]). Aborting. Errorin wlid. [operation ID 5149feef-10f3-443d-9cbe-87a29183ec98]
as: net.wimpi.modbus.ModbusSlaveException Error Code = 6 [operation ID be37bf86-04bd-4674-9a47-f0db89ff5981] es
2022-05-08 16:57:14.755 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 1 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=37000, length=18, maxTries=1]). Aborting. Erronvr was: net.wimpi.modbus.ModbusSlaveException Error Code = 6 [operation ID e73f794c-8f2e-437f-adcf-87525dbee575]
2022-05-08 16:57:15.265 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 1 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=37113, length=2, maxTries=1]). Aborting. Error was: net.wimpi.modbus.ModbusSlaveException Error Code = 6 [operation ID cbfa243f-0520-45f0-8c3c-0aaa9c8287e8] w
2022-05-08 16:57:15.776 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 1 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=32010, length=1, maxTries=1]). Aborting. Error was: net.wimpi.modbus.ModbusSlaveException Error Code = 6 [operation ID d27f7fa7-6906-498b-952b-f16579b0df70] es
2022-05-08 16:57:16.285 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 1 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=32009, length=1, maxTries=1]). Aborting. Errornv was: net.wimpi.modbus.ModbusSlaveException Error Code = 6 [operation ID be37bf86-04bd-4674-9a47-f0db89ff5981]
2022-05-08 16:57:16.787 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 1 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=47242, length=20, maxTries=1]). Aborting. The w
response did not match the request. Resetting the connection. Error details: org.openhab.core.io.transport.modbus.exception.ModbusUnexpectedTransactionIdException Transaction id of request (1908) does not equal response (1899). Slave response is invalid. [operation ID 5149feef-10f3-443d-9cbe-87a29183ec98] es
2022-05-08 16:57:19.243 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 1 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=37784, length=4, maxTries=1]). Aborting. The rnvesponse did not match the request. Resetting the connection. Error details: org.openhab.core.io.transport.modbus.exception.ModbusUnexpectedTransactionIdException Transaction id of request (1911) does not equal response (1908). Slave response is invalid. [operation ID c41e89e2-1764-41c3-b412-411d322c38ef]
2022-05-08 16:58:05.541 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘Inverter-2’ failed: Character I is neither a decimal digit number, decimal point, nor “e” notation exponential mark. in Inverter
2022-05-08 17:00:04.052 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 1 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=32010, length=1, maxTries=1]). Aborting. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: SocketTimeoutException Read timed out [operation ID 16a9fb1c-c5e8-443d-bc25-639afb8bf547]
2022-05-08 17:00:06.060 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 1 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=37113, length=2, maxTries=1]). Aborting. The response did not match the request. Resetting the connection. Error details: org.openhab.core.io.transport.modbus.exception.ModbusUnexpectedTransactionIdException Transaction id of request (2115) does not equal response (2112). Slave response is invalid. [operation ID 1bee68a6-00a0-4579-8236-ff93c1b87126]
2022-05-08 17:05:04.449 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 1 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=37113, length=2, maxTries=1]). Aborting. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: SocketTimeoutException Read timed out [operation ID 8074e415-f73e-4157-8573-042266dbc577]
2022-05-08 17:05:06.455 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 1 failed when executing request (ModbusReadRequestBlueprint [slaveId=2, functionCode=READ_MULTIPLE_REGISTERS, start=32010, length=1, maxTries=1]). Aborting. The response did not match the request. Resetting the connection. Error details: org.openhab.core.io.transport.modbus.exception.ModbusUnexpectedTransactionIdException Transaction id of request (2496) does not equal response (2493). Slave response is invalid. [operation ID c99feaf7-4fa7-4d49-9291-830f724d32d6]

Seem to be every 5mins or so an on the first and last poller of the Bridge, at least the last errors.
But no errors in the last 10minutes

By the way. Is anyone else experiencing error messages from the inverters, i.e. bits in 32008, 32009 or 32010 that come and go?

That’s the other end (this dongle) saying “Not now, I’m busy.”
Bit of clue where the issues lie, I’m not sure how else you can be less demanding of it though.

I saw this with parallel connections to dongle. If
You have two separate tcp connections SDongle will get crazy, it is able to send reply from first connection to the second. I collected a sample pcap with this and I am certain it happens because I saw a reply with completely odd transaction id from other openhab connection which ran much longer.

Hi @Andreas_Pircher,

you are using a super aggressive poller refresh of 2sec (refresh=2000) or 10sec (refresh=10000). You may reduce the poll rate by increasing the refresh to something larger - like I use 1min (refresh=60000). I guess the SDonge cannot cope with such a high poll rate.

Good luck!

It can under a primary condition: you have a single TCP connection to it which is retained over long time. I know that support advices polling of 5 secs or more but its not justified by anything but their promise.

This means that even if there is a failure with an payload or something else, connection should not be terminated. Otherwise you get into re-initialization cycle and re-establishment of RTU communication between dongle and inverter itself. The more reconnects you have, the less stable dongle is.
If you get two TCP connections (ie openhab and mbpoll or other agent), then SDongle will become unstable as well.

I made a test with an even more aggressive scan of 500 ms and 250 ms inter transaction gap and it worked just fine. I reverted to 5 secs to not spam storage with too much of power data. :slight_smile: I had two inverters and two dongles and both survived the same test.

… well, with a cascading setup where each inverter has its own ModbusID, I have to setup 2 Modbus TCP Slaves connecting to the single SDongle on the master inverter. This counts as multi-connection?

I see occational warnings on mismatching transaction IDs across both ModbusIDs as well as the 4 Modbus Pollers I have setup. I need to check the event timeline to see if there are specific conditions where the warnings occure. So far things work pretty good.

No, the openHAB binding is smart enough to run just one TCP connection for all pollers targeting one hostname/IP address.
BUT
for that to happen you must be careful to configure all the TCP settings the same. I think its hard to mess that up, the configure validation complains otherwise - check in the logs at binding startup time.
It is the dongle’s job to just pass the ID through to the serial bus.

So, no matter which device a transaction is associated with, we should be getting back sensible packet sequence numbers. All openHAB’s polls to different IDs are part of the same sequence.

The problem @splatch is describing is about two different servers polling the dongle, and the dongle sending the response to query from server “X” to server “Y” by mistake. “Server Y” might be a phone app, etc.

I think I’ve seen other gateways make the same mistake, probably to do with sending a serial response message to whichever server queried last (which isn’t necessarily the one that queried for that message).

Having said all that …

There is another way for this to happen.
openHAB has no control of the timeout the gateway allows on the serial side, we are relying on the TCP side timeout.
So let’s say OH sends a poll “A”, there’s no response for a while. OH timeout occurs, abandons it, logs it and starts the next poll “B”…
Meantime the serial response “A” arrives back at the dongle/gateway, which hasn’t timed it out, so it sends the late message “A” to OH.
OH is waiting for response to poll B, not A, and complains because it doesn’t match…

Easiest way to confirm this is running single endpoint at the time. If you get stable operations with single connection talking to single slave and failures with two then its issue of dongle. If even one slave is a problem then its issue of the configuration.

I would not be surprised if that thing would fail with two slaves. I saw it miss-behaving when I was changing tcp unit id as well.

5 posts were split to a new topic: Help with USB RS485 Converter

Hi all,

I try to connect OH 3.2 to a Huawei Sun 2000 via Modbus- TCP but I get this error every time.

2022-06-26 19:46:56.526 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 1 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=32000, length=1, maxTries=1]). Aborting. Error was I/O error, so resetting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: SocketTimeoutException Read timed out [operation ID c8b8319d-1054-41a4-9f27-b1e9cbb7ce52]

Modbus TCP Slave Thing:
UID: modbus:tcp:bdc5541c40
label: Modbus TCP Slave
thingTypeUID: modbus:tcp
configuration:
timeBetweenTransactionsMillis: 250
connectMaxTries: 3
reconnectAfterMillis: 1300
port: 502
timeBetweenReconnectMillis: 10000
host: 192.168.10.182
connectTimeoutMillis: 10000
afterConnectionDelayMillis: 2000
id: 1
enableDiscovery: false

Poller Thing:
UID: modbus:poller:bdc5541c40:23170e4020

Thanks in advance
label: Regular Poll
thingTypeUID: modbus:poller
configuration:
length: 1
start: 32000
refresh: 15000
maxTries: 1
cacheMillis: 50
type: holding
bridgeUID: modbus:tcp:bdc5541c40

IP- Inverter: 192.168.10.182
IP-Dongle: 192.168.10.183

I have the wLAN-Dongle and Modbus activated in the Huawei settings.

OH sent its poll, but there was no reply. Not much more we can tell from this end.

In general, check your IP address, routing, modbus ID.