I got two SUN200 (10KTL-M1) to integrate through SDongle and been struggling a lot to stabilize TCP connections. Turns out that dongle is doing RTU communication when it receives TCP packets so you can’t make instant modbus poll after connection is established cause it will not work.
Official support told me to wait 1-2 seconds before making a request after tcp connection is set up. I made some tests and it seems to help a lot as I haven’t seen inverters going offline or terminating connection.
Core issue and related changes to make it work reliably: [modbus] Support for an arbitrary delay after connection is made · Issue #2926 · openhab/openhab-core · GitHub.
Update with changes above I was able to get connection in a decent shape, key is not terminating TCP connection as long as it is operational and not repeating requests once they fail. I found SDongle getting very fragile in such situations. With long lasting connection it is working with 500ms/2 Hz sampling period for dc/ac power with no issues. Sample config:
UID: modbus:tcp:huawei_1
label: Huawei 1
thingTypeUID: modbus:tcp
configuration:
timeBetweenTransactionsMillis: "250"
connectMaxTries: "-1"
reconnectAfterMillis: "-1"
port: "1502"
timeBetweenReconnectMillis: "10000"
host: 127.0.0.1
connectTimeoutMillis: "10000"
afterConnectionDelayMillis: "2000" # new parameter available in OH 3.3
id: "1"
enableDiscovery: "false"
An additional finding. While doing field testing I lost for a bit hope as it didn’t work after patchwork. Eventually modbus binding started to report “not our request” errors which made me thinking if there is another connection, so there was another instance of OH running which did poll SDongle. It turns out that this thing (my firmware version is V100R001C00SPC127
) can’t handle two parallel TCP connections at once as it might be throwing modbus reply packets between them!