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_proberaisesUnsupportedModelErrorfor 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_poweris positive when discharging. async_read_raw()returns the raw register map for diagnostics; the mock backend'sload_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.0a3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sungrow_sht_modbus-0.1.0a3.tar.gz | 54.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sungrow_sht_modbus-0.1.0a3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 89.5 kB
Release files / sungrow_sht_modbus-0.1.0a3.tar.gz
| Download URL | sungrow_sht_modbus-0.1.0a3.tar.gz |
|---|---|
| Size | 54.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad366a54be6b7da701f3147ec8be1d340ab27eabe6733419f901927b8824ebc0
|
|
BLAKE2b-256 checksum How to use checksums |
96388268e27d49eb60f51e01c1b6b6e2243d562dce9a4b8058994676f4019b0c
|
| 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 13, 2026.
Transparency logRelease files / sungrow_sht_modbus-0.1.0a3-py3-none-any.whl
| Download URL | sungrow_sht_modbus-0.1.0a3-py3-none-any.whl |
|---|---|
| Size | 35.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
01c1aeccc6b88236b9f4aca216ff4e75d33bca11776a9755cfaf087bdef35200
|
|
BLAKE2b-256 checksum How to use checksums |
7af4a618dc750f5b0934fa266995beb20c3788480fad50502f140530ee746976
|
| 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 13, 2026.
Transparency log