huawei-solar
A Python wrapper for the Huawei Inverter modbus TCP API
What it is and what it does
huawei-solar is a Python library that abstracts the Modbus protocol to communicate with Huawei solar inverters (SUN2000), batteries (LUNA2000), and related devices. It provides both a low-level Modbus client for direct register access and a high-level device interface that handles register batching, unit conversion, and authentication. The library was originally developed to support Home Assistant integration but works as a standalone tool for any application needing to monitor or control Huawei solar equipment over local Modbus-TCP (via SDongle, EMMA, or WiFi) or Modbus-RTU (via RS485 serial connection).
The package depends only on tmodbus for Modbus protocol handling and supports modern Python versions (3.12, 3.13, 3.14). It includes features for reading optimizer data, writing battery parameters, and performing installer-level login sequences. The main constraint is that Huawei devices allow only one active connection at a time, so you must ensure no other client is attempting to connect while your session is active.
Use it for:
- Monitor real-time power output and voltage from a SUN2000 inverter in a home solar installation
- Read battery state-of-charge and temperature from a LUNA2000 battery connected to an inverter
- Integrate Huawei solar data into a Home Assistant automation or custom monitoring dashboard
- Write battery charge/discharge parameters or other settings to a Huawei device via Modbus
- Build a local energy management system that queries multiple inverter registers in a single batch operation
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Python interface to read and write data from Huawei SUN2000 inverters and LUNA2000 batteries over Modbus-TCP or Modbus-RTU, with support for batched register reads, unit conversion, and installer-level access.
Yes, if you own or manage Huawei SUN2000 inverters or LUNA2000 batteries and need local Modbus access. The package is actively maintained, has no known vulnerabilities, low install friction, and is marked Production/Stable. The AGPL v3 license is permissive for local use but requires source disclosure if you deploy modified versions as a network service. Not suitable if you need Python versions below 3.12.
Install
huawei-solar on PyPI
pip
pip install huawei-solaruv
uv add huawei-solarpoetry
poetry add huawei-solarInstalling huawei-solar
Before you install
Low install friction with a single runtime dependency (tmodbus). Actively maintained with a release 3 days old and recent commits; marked Production/Stable.
License in practice
Licensed under GNU Affero General Public License v3, which requires that if you modify and deploy this library as a network service, you must provide source code access to users. For local use or as a library in your own application, the copyleft obligation applies only if you distribute modified versions.
Quickstart
import asyncio
from huawei_solar import create_tcp_client, create_device_instance, SUN2000Device
from huawei_solar import register_names as rn
async def read_inverter():
client = create_tcp_client(host="192.168.1.1", port=503)
device = await create_device_instance(client)
result = await device.batch_update([rn.INPUT_POWER, rn.LINE_VOLTAGE_A_B])
print(result)
asyncio.run(read_inverter())
Requires Python 3.12 or later. Huawei devices support only one connection at a time; concurrent connections from other clients will interrupt your session.
Verify before relying
- Whether tmodbus has known vulnerabilities or maintenance issues not reflected in this package's security record
- Performance characteristics when reading large batches of registers or handling network latency
- Compatibility with specific SUN2000 firmware versions beyond the Huawei Modbus Interface Definitions
Package facts
| License | GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this… (full text in the JSON record) (agpl) |
| Python support | supports the current Python release (>=3.12) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — tmodbus |
| Maintenance | actively maintained — 3 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 135,982/month — #11,410 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: huawei_solar-3.0.7-py3-none-any.whl
Keywords: battery, huawei, inverter, modbus, modbus-rtu, modbus-tcp, solar, sun2000
Tags
More Home Automation packages
Represents and manipulates IPv4, IPv6, MAC…
permissive · top 5,000 on PyPI
homeassistantHome Assistant is an open-source home…
permissive · top 5,000 on PyPI
python-statemachineDefines finite state machines and statecharts…
permissive · top 5,000 on PyPI
btsocketA Python library for controlling BlueZ…
permissive · top 15,000 on PyPI
aiohomematicAn async Python library for controlling and…
permissive · top 15,000 on PyPI
hass-web-proxy-libProvides base classes and utilities for Home…
permissive · top 15,000 on PyPI
goodweConnects to GoodWe solar inverters over local…
permissive · top 15,000 on PyPI
pysmaConnects to SMA solar inverters via their…
permissive · top 15,000 on PyPI
pymodbusPyModbus is a complete Modbus protocol…
permissive · top 5,000 on PyPI
minimalmodbusMinimalmodbus provides a Python interface to…
permissive · top 15,000 on PyPI
pyenphaseProvides a Python library to communicate with…
permissive · top 15,000 on PyPI
pystiebeleltronProvides a Python API to communicate with…
permissive · top 15,000 on PyPI
uModbusuModbus is a pure Python implementation of the…
copyleft · top 15,000 on PyPI
pyModbusTCPA pure-Python Modbus/TCP client and server…
permissive · top 15,000 on PyPI
growattServerRetrieves photovoltaic system information from…
permissive · top 15,000 on PyPI
esdk-obs-pythonPython SDK for interacting with Huawei OBS…
permissive · top 15,000 on PyPI