Sungrow SG5.0RT Modbus

Hello everyone,
since yesterday we have solar panels with a Sungrow SG5.0RT inverter. I want to display the current AC power produced in Home Assistant with Modbus. I have already been successfull reading

  • Daily output Energy
    address: 5002
    data_type: uint16
    scale: 0.1
    precision: 1

  • Internal temperature
    address: 5007
    data_type: int16
    scale: 0.1
    precision: 1

This already shows in HA. For some reason I can’t read the Total output Energy (address 5003). This is all nice to have but I am actually interested in Modbus address 13007 (load power) which I can see in the iSolarCloud app and also directly on the WiNet-S (when entering it’s IP-Address into the browser).

Can someone help me with that?

probably data type is int32 (two registers)

I’ve made some progess… …I think, at least.

I made a small Python script to read a modbus register:

from pyModbusTCP.client import ModbusClient # pyModbusTCP needs to be installed via pip
import ctypes

address = '0.0.0.0' # IP-Address of the inverter
port = 502 # Port for Modbus
unit_id = 1
auto_open = True

modbus_client = ModbusClient(host=address, port=port, unit_id=unit_id, auto_open=auto_open)

data = modbus_client.read_input_registers(5030, 1) # Reads modbus register 5030

if data:
    signed16 = ctypes.c_int16(data[0]).value
    signed32 = ctypes.c_int32(data[0]).value
    print('Original data: ' + str(data)) # Unchanged data, directly read from Inverter
    print('Signed 16: ' + str(signed16))
    print('Signed 32: ' + str(signed32))
else:
    print('No data returned')

When executing the script, I get a value that matches with the value I was looking for on register 13007. I can see the value I want in the iSolarCloud app and when I enter the IP Address of the WiNet-S in the browser. This seems to be it.

I configured it in the modbus.yaml in Home Assistant like this:

- name: sungrow_inverter
  type: tcp
  host: 0.0.0.0
  port: 502
  sensors:
    - name: Leistung
      slave: 1
      address: 5030
      input_type: input
      unit_of_measurement: W
      state_class: measurement
      data_type: int16
      device_class: power

So, with that I would say that my problem is fixed.