Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

sungrow-sht-modbus

Asynchronous, transport-independent Python library for Sungrow SH-T hybrid inverters (SH5T–SH25T) over Modbus, built on modbus-connection.

The library does not own a connection: construct SungrowInverter(unit) with a modbus_connection.ModbusUnit from any backend (tmodbus, pymodbus, or the in-memory mock), call the update methods, and read typed attributes.

It is the backend of the sungrow Home Assistant integration in the same repository, and has no Home Assistant dependency.

Register map derived from Sungrow's Communication Protocol of Residential and Small Industrial Hybrid Inverter and from mkaiser/Sungrow-SHx-Inverter-Modbus-Home-Assistant (MIT) — see NOTICE.md at the repository root.

Usage

from modbus_connection import ModbusTcpParams
from modbus_connection.tmodbus import ModbusConnection

from sungrow_inverter import RetryingUnit, SungrowInverter

connection = ModbusConnection(ModbusTcpParams(host="192.168.1.50", port=502))
try:
    # A WiNet-S answers Modbus exception 4 now and then under contention;
    # RetryingUnit retries those (and timeouts), never real refusals.
    unit = RetryingUnit(connection.for_unit(1))

    probe = await SungrowInverter.async_probe(unit)  # identity only; gates on SH-T
    inverter = SungrowInverter(unit, model=probe.model, battery_max_power_w=12000)

    await inverter.async_update_realtime()  # measurements: poll every ~10 s
    await inverter.async_update_settings()  # settings, limits, energy, alarms: ~60 s

    print(inverter.flows.running_state, inverter.flows.power_flow)
    print(inverter.battery.battery_level, inverter.battery_power.battery_power)
    print(inverter.settings.ems_mode, inverter.battery_limits.max_charge_power)
finally:
    await connection.close()
  • async_probe raises UnsupportedModelError for any non-SH-T device type code, naming the model when it is a known Sungrow inverter.
  • The first update reads the identity block, restricts the MPPT 3 fields on two-MPPT models, probes the optional blocks (firmware strings, alarms, start power, the APL shadow) and fixes the poll lists. Nothing is written.
  • Each update returns an UpdateReport: which components refreshed and which failed with what. A connection loss is raised; one refused block only marks its component failed.
  • Addresses are protocol addresses (register − 1); 32-bit values use the low word first; battery_power is positive when discharging.
  • async_read_raw() returns the raw register map for diagnostics; the mock backend's load_raw() replays it.

scripts/query.py reads a real inverter once and prints everything:

uv run --package sungrow-sht-modbus python packages/sungrow-sht-modbus/scripts/query.py \
    "$SUNGROW_HOST" --unit "${SUNGROW_UNIT:-1}" --raw .testdata/raw.json

The --raw dump replaces the serial number with A123456789 unless --keep-serial is passed. Never commit a dump that carries a real serial.

Metadata

Release files for sungrow-sht-modbus 0.1.0a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sungrow-sht-modbus 0.1.0a1
File Size Uploaded
sungrow_sht_modbus-0.1.0a1.tar.gz 52.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sungrow-sht-modbus 0.1.0a1
File Interpreter ABI Platform
sungrow_sht_modbus-0.1.0a1-py3-none-any.whl Python 3 none any Details

Total release size: 87.1 kB

Release files / sungrow_sht_modbus-0.1.0a1.tar.gz

Download URL sungrow_sht_modbus-0.1.0a1.tar.gz
Size 52.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ec1d1a634701fa741d9c16f7ad54d9ecd530e2dcd696b6b8124324395080cc29
BLAKE2b-256 checksum
How to use checksums
7008324111a74048f855124e89c24424d9a4325de703596635d042195e66666c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / sungrow_sht_modbus-0.1.0a1-py3-none-any.whl

Download URL sungrow_sht_modbus-0.1.0a1-py3-none-any.whl
Size 34.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
201b56391add86dbdbdfc89817a664efee5d17e9cb207b284e5960fecea2fd16
BLAKE2b-256 checksum
How to use checksums
668f29de21cf0d0cc896c0305c8494ca828b39355a81f1a585f14e7cadcfca3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page