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

i am currently try to fix my issue with the times coming from the inverter.
I like to update the system time and timezone of the inverter with the modbus interface

The definition of the modbus poller are defined like this and the data are coming from the inverter properly


Bridge poller slave108holding [ start=40000, length=2, refresh=60000, type="holding" ]{            
        
        Thing data SystemTimeNumber [ readStart="40000", readValueType="uint32", writeStart="40000", writeValueType="int32", writeType="holding", updateUnchangedValuesEveryMillis="5000000" ]  
    }

Bridge poller slave108aholding [ start=43006, length=1, refresh=360000, type="holding" ]{            
        
        Thing data TimeZone [ readStart="43006", readValueType="int16", writeStart="43006", writeValueType="int16", writeType="holding",updateUnchangedValuesEveryMillis="5000000" ]  
    }

in the modbus interface description we have

SN Signal Name    Read/Write  Type Unit Gain Address   Quantity Scope
42 System Time    RW          U32  N/A  1    40000     2        [946684800, 3155759999] Epoch seconds,local time
56 Time zone      RW          I16  min  1    43006     1        [-720,840]

if i send a item update via the karaf console for the item timezone
openhab:send TimeZone 120

12:02:45.812 [WARN ] [ort.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusWriteRegisterRequestBlueprint [slaveId=1, reference=43006, registers=ModbusRegisterArray(0078), maxTries=3, getFunctionCode()=WRITE_SINGLE_REGISTER]). Will try again soon. Error was: net.wimpi.modbus.ModbusSlaveException Error Code = 128 [operation ID c6f5634d-9ca7-420a-8f6f-4f7e224414b2]
12:02:47.037 [WARN ] [ort.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusWriteRegisterRequestBlueprint [slaveId=1, reference=43006, registers=ModbusRegisterArray(0078), maxTries=3, getFunctionCode()=WRITE_SINGLE_REGISTER]). Will try again soon. Error was: net.wimpi.modbus.ModbusSlaveException Error Code = 128 [operation ID c6f5634d-9ca7-420a-8f6f-4f7e224414b2]
12:02:48.259 [ERROR] [ort.modbus.internal.ModbusManagerImpl] - Last try 3 failed when executing request (ModbusWriteRegisterRequestBlueprint [slaveId=1, reference=43006, registers=ModbusRegisterArray(0078), maxTries=3, getFunctionCode()=WRITE_SINGLE_REGISTER]). Aborting. Error was: net.wimpi.modbus.ModbusSlaveException Error Code = 128 [operation ID c6f5634d-9ca7-420a-8f6f-4f7e224414b2]
12:02:48.260 [DEBUG] [ternal.handler.ModbusDataThingHandler] - Thing modbus:data:slave100:slave108aholding:TimeZone 'Modbus Data' had ModbusSlaveErrorResponseExceptionImpl error on write: ModbusSlaveErrorResponseException(error=128)
12:02:48.261 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:slave100:slave108aholding:TimeZone' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error (ModbusSlaveErrorResponseExceptionImpl) with write. Request: ModbusWriteRegisterRequestBlueprint [slaveId=1, reference=43006, registers=ModbusRegisterArray(0078), maxTries=3, getFunctionCode()=WRITE_SINGLE_REGISTER]. Description: ModbusSlaveErrorResponseException(error=128). Message: Slave responsed with error=128

Has anybody successfully tried to write back the timezone or the time?
Any hint would be welcomed , thx

What numeric values do you actually want to write? You might need a transformation.

Your device might prefer “write multi”, Modbus FC16, indeed almost certainly needs that for the 32-bit value.

as shown in the karaf console i am updating the item with a new number
my assumption is that the modbus binding converts the number item to the corresponding ```
writeValueType=“int16”

The error message did not really indicates if this is an conversion issue.
I did not find something about the error code 128

I can’t see the value you are writing.

Yes. Does your device allow you to write just one register?

This is information you need from Huawei, that is what is rejecting your write attempt. They can be applying any rules they like, like only allowing 30 minute intervals or only write by FC16.

well the modbus interface description tags the registered as indicated in post #86

for writing the following is described in the huawei description

Frame Format for a Normal Response from a Slave Node
Data Field Length Description
Function code 1 byte
0x06
Register Address
2 bytes
0x0000–0xFFFF
Register Value
2 bytes
0x0000–0xFFFF

I will also open an support case in the huawei support line

l operate 32 optimzer.

I am able to get general information like Optimzer total number, Amount of online and a sequence number indicating a new file can be uploaded.
In the modbus description it is written that if the sequence number is increasing a file can be uploaded from the inverter that give some monitoring of the optimizer

I am using the modbus binding from openhab and i could not find any feature description that handles files.
Does any body have some java or python scripts that you can share with the community?

There are no file transfer standards for Modbus. This’ll be some HTTP API perhaps.

I have now managed to read out the inverter. To implement a PV excess charge, I need the current load in my house. I have connected a DTSU-666H to the inverter. Can I read it out? Which register do I have to use?

Try this

Bridge poller slavepowermeter [ start=3700, length=115, refresh=1000, type="holding" ]{
    
        Thing data Powermeter                        [ readStart="37113", readValueType="int32",updateUnchangedValuesEveryMillis="5000000" ]
        Thing data Battery charge-discharge power    [ readStart="37001", readValueType="int32",updateUnchangedValuesEveryMillis="5000000" ]
        Thing data Current-day charge capacity       [ readStart="37015", readValueType="int32",readTransform="JS(divide100.js),updateUnchangedValuesEveryMillis="5000000" ]
        Thing data Current-day discharge capacity    [ readStart="37017", readValueType="int32",readTransform="JS(divide100.js),updateUnchangedValuesEveryMillis="5000000" ]

If you have a fresh install you can folow this tutorial and have everything in the GIU

Thank you for your help. I get values ​​from the inverter via register 37113. However, these are not valid. The current load is around 500W, I get values ​​from -400 to -600

Bridge poller slavepowermeter [ start=37113, length=2, refresh=1000, type="holding" ]
{
  Thing data Powermeter	[ readStart="37113", readValueType="int32",updateUnchangedValuesEveryMillis="5000000" ]
 }

When the value is - you are taking power from the grid.You can raise the refresh to make the value more Stable.

Thanks … I could have come up with that myself

Concerning the optimizer information from the inverter.
the following info can be added to the modbus definition.

add this poller to your bridge

Bridge poller slave109holding [ start=37200, length=3, refresh=60000, type="holding" ]{
    
        Thing data OptiTotal  [ readStart="37200", readValueType="uint16",updateUnchangedValuesEveryMillis="5000000" ]
        Thing data OptiOnline [ readStart="37201", readValueType="uint16",updateUnchangedValuesEveryMillis="5000000" ]
        Thing data OptiSeq    [ readStart="37202", readValueType="uint16",updateUnchangedValuesEveryMillis="5000000" ]
   }

here the relevant items.

Number              OptiTotal "Total Number of Optimizer [%d]"  {channel="modbus:data:slave100:slave109holding:OptiTotal:number"}
Number              OptiOnline "Number of Online Optimizer [%d]"  {channel="modbus:data:slave100:slave109holding:OptiOnline:number"}
Number              OptiSeq "Sequence Optimizer [%d]"  {channel="modbus:data:slave100:slave109holding:OptiSeq:number"}

concerning the additional info per optimizer i got this document from huawei support.
modbus_V3.pdf (730.9 KB)

any hint on how to implement the sequence of modbus calls with the existing modbus binding?
Or is this something can can only be done by an external script?

If you refer to 6.3.7.1 “Uploading Files” using “Huawei defined function 0x41”, no, the binding does not support nonstandard functions such as 0x41 Huawei uses.

I need to read/extract data about production of energy from Inverter Sun2000 6KTL-M0 with WlanDongle and smart smart meter DTSU666H .

I want to use a raspberry pi to command a relay/switch/ boiler/heat-pump when PV system start to export to grid energy or to stop when i don`t have energy from PV .

1.With a user " owner" is possible to read this data ?

2 .from Modbus what info are available for this issue ?

3 .What data from register map are relevant for this operation ?

  1. from smart meter DTSU666H what data are available ?

5 .Is necessary extra hardware for this functions?

You can use it as a custom component: GitHub - Emilv2/huawei_solar: Home Assistant custom component for Huawei inverters.

Currently there seem to be some issues with it and the latest HA version, I will be working on it again soon.

@kreutzer_peter

If you still have issues interpreting the time, you can take a look at my python code: Emil Vanherp / HuaweiSolar · GitLab

Concerning the extra optimizer data, I also tried to access it but failed. Please tell me if you manage to get it!

Is there a way to get the SOC and SOH state of the battery storage through modbus?
I couldn’t find anything similar in the docs.

For those interested there are new modbus definitions with battery soc and more.

I’m planning to buy a Huawei SUN2000-2KTL-L1 which already has wifi, and a Huawei SMART POWER SENSOR DDSU666-H that will use its RS485 port. Can I use the integrated wifi to connect to OpenHab ? Or do I need to buy the SDongle ?

You need the sdongle.

1 Like