Sungrow Inverter integration with TCP Modbus (readonly)

Hey there, I want to share my experience with adding an Sungrow inverter to openHAB using Modbus.

Hybrid Inverters (SH- Models)

If you have an ‘SH-…’ inverter, here is a binding that makes the setup very easy.

Since my model is an ‘SG…’ I had to configure Modbus manually.

Grid Connected Invertes (SG- Models)

Tested with an SG8.0RT and openHAB 4.1.1

  1. Install the modbus binding from the ‘Add-on Store’

  2. Set up a ‘Modbus TCP Slave’ thing

    • host = the host name or IP of your inverter. (tested only with LAN in my case)
      Keep the other values unchanged.
  3. Set up a ‘Modbus Regular Poll’ thing

    • Parent Bridge = the Modbus TCP Slave from step 2
    • Poll Interval: I changed it to 5000ms but the default (500) should work too.
    • Start: here you have to choose a register number. As an example, here is a document containing register values for many Inverters. Keep in mind that you have to subtract “1” from the target value. So “Total Active Power = 5031” becomes “5030”.
    • Length: this is the length of a sequence of registers that will be loaded. To load one register, choose ‘1’, to load two (in a row) ‘2’ and so on.
    • Type: for read only, I had to choose ‘input register’.
  4. Set up a Modbus Data thing for every value you want to read from the Inverter

    • Under ‘Thing’ tab:
      • Parent Bridge = Modbus Regular Poll thing from step 3
      • Read Address: the register number you want to read. Keep in mind to subtract ‘1’ like mentioned in step 3.
      • Read Value Type: The value type can be found in the linked document in the “Data type” column.
        U16 in the documentation becomes 16bit unsigned integer (uint16) in openHAB.
        S1616bit signed integer (int16)
        U3232bit unsigned integer, 16bit words swapped (uint32_swap)
        S3232bit signed integer, 16bit words swapped (int32_swap)
        UTF8 not tested.
    • Under ‘Channel’ tab
      • Link an item to the channel type that fits your data.

That’s it.

It’s my first tutorial here. If you find mistakes or want to give me a feedback feel free to reply!
Also the formatting makes me not happy. Maybe it’s not very readable…

EDIT: 2024-03-13

Value Transformation

Today I added the Daily Earnings (register 5003).
The configuration is the same except the value transformation.
As described in the ‘Communication Prococol’ document (Step 3) this value shipps as 0.1kWh. So ‘5.3kWh’ becomes ‘53’ through the Modbus. To deal with this, I’ve written a simple transformation with the ID ‘divideByTen’ in JavaScript (JS). It has no Unit of Measurement so it can be used for other purposes too.

(function(data) {
  if(data == "NULL" || data == "UNDEF") return data;
  return parseFloat(data) / 10;

Now I’ve choosen to apply this in the thing configuration so every linked item has kWh as value instead of ‘tenth part of kWh’.
To do so, in step 4 I additionally changed default of the field ‘Read Transform’ to JS(config:js:divideByTen).

At least I linked a corresponding item and defined ‘Dimension’ as ‘Energy (kWh)’.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.