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.0a2

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.0a2
File Size Uploaded
sungrow_sht_modbus-0.1.0a2.tar.gz 52.9 kB Details

Built distribution (wheel)

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

Total release size: 87.7 kB

Release files / sungrow_sht_modbus-0.1.0a2.tar.gz

Download URL sungrow_sht_modbus-0.1.0a2.tar.gz
Size 52.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e09e301618f49822ccfb8869f8c7dc285f35969de62eadb3aeb8c0d632281f49
BLAKE2b-256 checksum
How to use checksums
df3e79228fddbe847e26914424babca5ea274bbafeaded1238c2d75568bd1319
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.0a2-py3-none-any.whl

Download URL sungrow_sht_modbus-0.1.0a2-py3-none-any.whl
Size 34.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d91eeb36b032a3d6f0c4da96da72cec59a3ec5ccbab236b5a952475a049e22b
BLAKE2b-256 checksum
How to use checksums
e72eea7ac128e47e9e00920d336dc3519853f11ec96ff12a760b04f35254ec11
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