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

Thank you for the tutorial!
We’re considering a solar system with Huawei SUN2000 and LUNA2000 battery, and I have a couple of questions and hope to get some help here:

  1. My supplier quote me the model SUN2000-8KTL-M1, I see there is a newer version M2/M3. Anybody know the difference?
  2. My supplier told me the inverter comes with WiFi, so I still need to buy Huawei Smart Dongle-WLAN-FE?
  3. I read that we can read data from Modbus, can we make changes? I’m thinking change TOU based on electricity price and weather etc.
    Many thanks in advance!

I’ll try to answer some questions.
As for number 1, see here https://forum.huawei.com/enterprise/en/model-m1-oder-m2/thread/667280853836906496-667213868771979264
2. My installation came with the dongle, but I’ve read that you could possibly make it work without it as well. I don’t know. Just make sure that modbus communication is enabled (at least for the dongle is must be enabled separately)
3. I haven’t tried, but I don’t see any reason why it wouldn’t work as long as the inverter supports changing the setting. See the modbus guide for the inverter for details.

And as a side note. My ground source heat pump can directly read the inverter and adjust itself based on that. But the pump and openHAB can’t both communicate with it so I had to install modbus proxy which communicates with the inverter and then the pump and openHAB talk to the proxy. Works at least as well as openHAB directly to the inverter…

1 Like

Thanks for your reply! I will check with my supplier regarding the smart dongle.
It’s smart solution with the heat pump, which brand is it? We have an old ground source heat pump with Modbus but I don’t think I can control the power consumption.

We have a Nibe S1255. It’s not that obvious in the menu, but when you dig deep enough, there are setting for connecting to solar panels/inverter in there

1 Like

openHAB 3.3.0 on Raspberry PI

I do get the Values from the Huawei inverter. Something seems to be wrong with the transformation though. I do get these errors:

I have placed all mentioned files in the transform folder:
transform

Can anybody give me a hint what I am doing wrong and how I can solve the Problems?
I already tried a complete re-boot. But this did not help.

JavaScript addon needs to be installed also it complains a 0-1.map is missing in the transformation folder so just create a file named lie that and inside put like

0=off
1=on
1 Like

Thank you for the help. I had to install the MAP transformation too. Now everything works fine.

Hello everyone,
I’m still having problems with stability of the Things. Is there any best practice for the Thing configuration?
This is my current setup, but some Things are regularly going offline:

modbus:tcp:localhostTCP
host=“192.168.178.173”
port=502
id=1
reconnectAfterMillis=60000
timeBetweenTransactionsMillis=2000
timeBetweenReconnectMillis=3000
afterConnectionDelayMillis=2000
connectTimeoutMillis=10000

poller slave105holding
start=32078
length=13
refresh=10000
maxTries=1
type=“holding”

I’m using a wired connection to the Huawei Dongle, so network should be no issue.

I have it running nearly without problems.
Regularly some errors but no reset of connection.
I will post my values in the evening.

At first you should change the max. tries to 3.
This avoids for me that the connection is reset every few minutes.

Interesting… Other posts clearly state that retries should be deactivated… :upside_down_face:

Retries are helpful if you have available enough of bandwidth on the bus. In case of stick - it might be simply too busy to answer first attempt, by adding retries you make it busier. If you are near bandwidth it also means that other polls will be delayed.
Advice I got from Huawei support two years ago was quite clear - in case of failure do not retry, let usb stick get and come back with next polling cycle.

Obviously it does not make OH binding happy, because it marks poller offline and can trigger monitoring rules.

Following my settings of the inverter.
I have one inverter and powermeter installed.

thingTypeUID: modbus:tcp
configuration:
  rtuEncoded: false
  connectMaxTries: 3
  reconnectAfterMillis: 0
  timeBetweenTransactionsMillis: 2500
  port: 502
  timeBetweenReconnectMillis: 150
  connectTimeoutMillis: 100000
  host: 192.168.1.170
  afterConnectionDelayMillis: 800
  id: 1
  enableDiscovery: false

Following a excert of the log with 3 retries:

2023-11-16 17:17:03.003 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Powermeter_ValueasNumber' changed from -913 W to -868 W

==> /var/log/openhab/openhab.log <==

2023-11-16 17:17:26.620 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=32016, length=8, 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 797e936d-43fc-43fe-8cd6-29f23d1d159c]

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

2023-11-16 17:17:35.721 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TimestampPowermeter' changed from 2023-11-16T17:17:02.963787+0100 to 2023-11-16T17:17:35.712755+0100

2023-11-16 17:17:35.725 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Powermeter_ValueasNumber' changed from -868 W to -832 W

==> /var/log/openhab/openhab.log <==

2023-11-16 17:17:53.573 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=32064, length=31, 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 81798adb-13be-463a-addf-27f04e331467]

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

2023-11-16 17:18:16.051 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TimestampPowermeter' changed from 2023-11-16T17:17:35.712755+0100 to 2023-11-16T17:18:16.041686+0100

2023-11-16 17:18:16.073 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Powermeter_ValueasNumber' changed from -832 W to -861 W

==> /var/log/openhab/openhab.log <==

2023-11-16 17:18:30.519 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=32016, length=8, 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 e09473b8-d09b-4c73-9c54-e440b6a8021b]

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

2023-11-16 17:18:52.009 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TimestampPowermeter' changed from 2023-11-16T17:18:16.041686+0100 to 2023-11-16T17:18:51.996514+0100

2023-11-16 17:18:52.012 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Powermeter_ValueasNumber' changed from -861 W to -848 W

==> /var/log/openhab/openhab.log <==

2023-11-16 17:18:57.504 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=32002, length=1, 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 1d8715c7-6317-441c-9f46-42b9efaabd01]

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

2023-11-16 17:19:28.530 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TimestampPowermeter' changed from 2023-11-16T17:18:51.996514+0100 to 2023-11-16T17:19:28.520774+0100

2023-11-16 17:19:28.533 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Powermeter_ValueasNumber' changed from -848 W to -860 W

A lot of warnings but no connection dropped.

Hi @bobelhage, did you - or anyone else - eventually succeed in writing (single) registers? I’m currently at the stage you were back then, reads work great, but writes don’t so anything, although the openHAB debug log states “Succesful write”. Thanks!

Hi Fernando,
Could you send me the modbus configuration, I’d like to set up a similar conf.
Thanks alot!!!
Georges

I will send you through PM. You’ve the smartlogger or without smartlogger?

I solved my problem. After I updated all Huawei components to the latest firmware version, I can write registers successfully.

Hello, does anybody try to implement this in OH4?
I’ve give it a try with the tutorial for OH3 but unfortunately that doesn’t seem to work.
I’am new to openhab and sure there will be some implementation differences between OH3 and OH4.

I’m trying to set it up with my OpenHab 4.

My SDongle version is V100R001C00SPC125

I have already change a Dongle parameter to Enable (unrestricted) in the Modbus-TCP configuration, so I have a connection from the openhab host to the inverter

pi@HOME:/etc/openhab/things $ telnet 192.168.1.28 502
Trying 192.168.1.28...
Connected to 192.168.1.28.
Escape character is '^]'.

I have two things configured as following:

UID: modbus:tcp:444a6f5e4d
label: Modbus TCP Slave
thingTypeUID: modbus:tcp
configuration:
  rtuEncoded: false
  timeBetweenTransactionsMillis: 1500
  connectMaxTries: 3
  reconnectAfterMillis: 0
  port: 502
  timeBetweenReconnectMillis: 10
  host: 192.168.1.28
  connectTimeoutMillis: 10000
  id: 1
  enableDiscovery: false

UID: modbus:poller:444a6f5e4d:slave102
label: Regular Poll
thingTypeUID: modbus:poller
configuration:
  start: 37000
  length: 115
  refresh: 10000
  maxTries: 3
  cacheMillis: 50
  type: holding
bridgeUID: modbus:tcp:444a6f5e4d

The settings has been taken from thing file listed there: Reading data from Huawei inverter SUN 2000 (3KTL-10KTL) via modbus TCP and RTU with json configuration for full GIU control

Unfortunately OH4 complains about the connection

2023-12-30 17:23:12.433 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=37000, length=115, 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 cd56dadc-c9ec-4d9d-9f08-ea6af36eb6fb]
2023-12-30 17:23:27.824 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=37000, length=115, 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 9f41974f-72c9-4623-ac31-265201100a9d]
2023-12-30 17:23:42.727 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=37000, length=115, 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 bfd45434-4e27-43b5-8cbf-360b2226d157]

Can someone help there?

The modbus slave thing misses afterConnection delay parameter.

Thanks a lot! I don’t have a warning anymore, so I guess it’s a good sign and the connection has been established.

I have tried to add a new thing, which would read a data. I took the first from the list:

UID: modbus:data:slave102:Rated_power
label: Rated_power
thingTypeUID: modbus:data
configuration:
  readValueType: uint32
  readTransform: JS(divide1000.js)
  readStart: "30073"
  updateUnchangedValuesEveryMillis: 5000000
bridgeUID: modbus:poller:444a6f5e4d:slave102

However the one has readStart=30073, since my poll starts from 37000. Obviously it creates an issue

CONFIGURATION_ERROR
Out-of-bounds: Poller is reading from index 37000 to 37018 (inclusive) but this thing configured to read 'uint32' starting from element 30073. Exceeds polled data bounds.

When I tried to lower ‘start’ in the poll configruration, however after that change I have SocketTimeoutException any. I’m confused about the ‘start’ configuration in the poll. In this topic it looks like people are using any random number between 30000 and 37000. What is a proper setup?