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

I was looking into this and noticed they talk about port 502 for older firmwares.

I tried to netcat that one and I got connection successfull.

Should I try and use that port? And if so, how can I try to extract information using OH?

If 502 is open then use it.

All info in first post of this thread.

1 Like

Tried with the exact configs there (since the inverter is exactly the same) but I am getting these error messages:

2023-05-23 18:25:42.774 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=30073, length=10, 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 a77bff44-d102-4c1a-9183-79f31112a0da]
2023-05-23 18:25:45.840 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=30073, length=10, 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 a77bff44-d102-4c1a-9183-79f31112a0da]
2023-05-23 18:25:48.906 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 3 failed when executing request (ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_MULTIPLE_REGISTERS, start=30073, length=10, maxTries=3]). 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 a77bff44-d102-4c1a-9183-79f31112a0da]

Install QModBus and see if you can read any data. In my case, until I’ve set Local O&M to on, all read attempts returned zero.

1 Like

Hi,

does anyone know what to do to gain write access to the RW Modbus registers when connected to the Inverter WLAN?
I do have read access and can pull all registers of interest. But when writing a register I get an error message:

2023-06-13 16:56:54.318 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 2 failed when executing request (ModbusWriteRegisterRequestBlueprint [slaveId=0, reference=47087, registers=ModbusRegisterArray(0001), maxTries=2, getFunctionCode()=WRITE_SINGLE_REGISTER]). Will try again soon. Error was: net.wimpi.modbus.ModbusSlaveException Error Code = 128 [operation ID e1971f36-2a87-40f2-a688-9cc232b0fc9e]
2023-06-13 16:56:56.351 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 2 failed when executing request (ModbusWriteRegisterRequestBlueprint [slaveId=0, reference=47087, registers=ModbusRegisterArray(0001), maxTries=2, getFunctionCode()=WRITE_SINGLE_REGISTER]). Aborting. Error was: net.wimpi.modbus.ModbusSlaveException Error Code = 128 [operation ID e1971f36-2a87-40f2-a688-9cc232b0fc9e]

“Error Code = 128” means “no permission”. In Home Assistant there is a mode to enable “elevated rights” to allow write access. So what do I need to do to get “elevated rights” in OpenHab?

Thanks!

Dear Mario, can you share your transformation files?

many thanks in advance

Hi,

does anyone have a modbus TCP documentation, or does anyone know the modbus port for total consumption?
I couldn´t find out which readstart i should use.

I have the active power an the power to grid, but a also want to know the actual comsumption.
Maybe this vaule is also available over modbus.
Otherwise i have to calculate the value.

BR
Vaillan

As far I can understand what PV inverter does, I doubt if you will find a consumption data on inverter side. This kind of information needs to be sourced from electric meter.
For total yield (produced AC reflected in Wh) there is a register, I’ll look for it and update my answer.

You are right, the smart meter measure this vaule.
But the power to grid also, and i can get this value also on modbus, so hope there is also one for the consumption.
Hopefully you can find something.

BR
Vaillan

Use register 32106, read value type uint32. As far I remember you need to scale it in order to get desired value. I have some old config with $value/100 to get total yield in kWh.

Hi, Thanks.
That´s the total yield, but a need actual consumption.
So actual power minus exported power - both values are available over Modbus, so i thought there is also a value for the consumption.

If there is no possibility, i will calculate it over a rule.

BR
Vaillan

Exported power is again available at electric meter. Is your inverter connected to a meter which you can see i.e. in huawei app?

I also have a question about a value where I dont know which modbus register to use.
There is modbus register 32114 “Daily Energy Yield in kWh”. I thought this returns the yield which came from the roof produced today. But I was wondering because this value was often ofer 2 kWh before sunrise. When looking into the Huawei app I find two values showing “Yield today” - the first one is on the start page; the other on is shown when going into the Devices tab under the Inverter.
It seems that the above mentioned modbus register is showing the 2nd one which I assume also considers Charge- and Discharge capacity. → the 2kWh before sunrise come from the battery which has been discharged during the night.
My question is: Does anybody know if there is also a modbus register for the “Yield today” showing on the first page of the app, meaning pure solar energy produced today (without battery)?

Hello! Sorry I was on vacation…

This is my transform file divide10.js:

// Wrap everything in a function (no global variable pollution)
// variable "input" contains data passed by openHAB
(function(inputData) {
    // on read: the polled number as string
    // on write: openHAB command as string
    var DIVIDE_BY = 10;
    return parseFloat(inputData) / DIVIDE_BY;
})(input)

I have no idea if this is needed or for what it is used in the end…sorry!

1 Like

I do not have batteries connected and in my case Yield today in the app (first page) is equal to the value from 32114 register.

Thanks for your reply. I guess it is related to the attached battery. In the meantime I found this.

The “Daily Yield” reported by the inverter is the output yield of the inverter, and not the input from your solar panels. For installations which have a battery connected to it, this is a significant difference: it includes the yield from discharging the battery, but misses the yield used to charge the battery. FusionSolar computes the “Yield” by combining the values from “Daily Yield”, “Battery Day Charge” and “Battery Day Discharge”

That is what I already assumed - so thats why I use a formula to calculate my yield coming from the solar panels.

I have another question about the update interval of the different modbus registers.

What I learnt so far is that I can set a refresh interval for each poller. For each Thing I can also set “updateUnchangedValuesEveryMillis”.

In my example I want to see the “Input_Power” (register 32064) every 20seconds.
This is how my poller definition looks like:

Bridge poller slave105holding [ start=32064, length=31, refresh=20000, type="holding" ]{

The Thing definition is:

Thing data Input_power  [ readStart="32064", readValueType="int32",readTransform="JS(divide1.js)"]

→ I removed the “updateUnchangedValuesEveryMillis” parameter of the Thing.

Nevertheless I see data coming always approx. at least every 60 seconds.

2023-07-20 11:51:35.644 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Input_power' changed from 1788.0 to 978.0
2023-07-20 11:52:58.965 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Input_power' changed from 978.0 to 826.0
2023-07-20 11:53:47.529 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Input_power' changed from 826.0 to 762.0
2023-07-20 11:54:47.956 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Input_power' changed from 762.0 to 746.0
2023-07-20 11:55:47.414 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Input_power' changed from 746.0 to 717.0
2023-07-20 11:57:24.302 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Input_power' changed from 717.0 to 706.0

So changing the refresh interval and the “updateUnchangedValuesEveryMillis” is not affecting my update interval.
a) am I doing sth wrong?
b) or is the inverter providing the data only every minute?

TCP with 15000 ms is working fine so far.

Especially for “active power” I would like to have a faster polling rate.

If I would switch to RTU, can I have a faster polling rate?

Has anyone managed to read the optimizers yet?

I can confirm that RTU is working with 1000 ms without any problem.