Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 3.2.4 instead.
Reason given by maintainers: Broken EMMA initialization

Homepage GitHub License Release Python Versions Testing

Python library for connecting to Huawei SUN2000 Inverters over Modbus

This library implements an easy to use interface to locally connect to Huawei Solar devices over Modbus-TCP or Modbus-RTU following the 'Solar Inverter Modbus Interface Definitions' provided by Huawei.

It was primarily developed to add support for Huawei Solar inverters to Home Assistant, resulting in the following integration: wlcrs/huawei_solar.

Supported devices:

  • SUN2000 inverters
  • LUNA2000 batteries (when connected to SUN2000)
  • EMMA
  • SCharger (when connected to EMMA)

Features:

  • Modbus-TCP support: connecting to the inverter via the SDongle, EMMA, or over the WiFi-AP (SUN2000-<serial_no>) broadcasted by the inverter
  • Modbus-RTU support: connecting to the inverter via the RS485A1 and RS485B1 pins on the COM port
  • Batched reading of Modbus registers and converting them into the correct units
  • Reading Optimizer data via the specialized 'file' Modbus extension
  • Writing to Modbus registers (mostly useful for setting battery parameters)
  • Performing the login sequence to gain 'installer'-level access rights

Installation

This library is published on PyPI.

Basic usage

The library consists out of a low level interface implemented in modbus_client.py which implements all the Modbus-operations, and a high level interface in huawei_solar/devices which facilitates easy usage (primarily meant for the HA integration).

Using the high level 'Devices' interface

An example on how to read the most interesting registers from the inverter:

import asyncio

from huawei_solar import (
    SUN2000Device,
    create_device_instance,
    create_tcp_client,
)
from huawei_solar import register_names as rn


async def test() -> None:
    """Run test."""
    client = create_tcp_client(host="192.168.1.1", port=503)
    device = await create_device_instance(client)

    assert isinstance(device, SUN2000Device)
    print(
        await device.batch_update(
            [
                rn.INPUT_POWER,
                rn.LINE_VOLTAGE_A_B,
                rn.LINE_VOLTAGE_B_C,
                rn.LINE_VOLTAGE_C_A,
            ]
        ),
    )


if __name__ == "__main__":
    asyncio.run(main())

This results in the following output being printed:

{'input_power': Result(value=82, unit='W'), 'line_voltage_A_B': Result(value=233.4, unit='V'), 'line_voltage_B_C': Result(value=0.0, unit='V'), 'line_voltage_C_A': Result(value=0.0, unit='V')}

Frequently asked questions

Q: the connection is interrupted a few seconds after connecting to the Huawei Device. How do I solve this?

A:: Huawei devices only support one connection at a time. If your connection is interrupted, this is typically because another device is trying to (re-)connect to it. Disable that device and try again.

Acknowledgements

The initial implementation of v1 was done by @Emilv2.

Subsequent development on v2 was done by @wlcrs.

Metadata

Release files for huawei-solar 3.2.0

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

Source distribution (sdist)

Source distribution for huawei-solar 3.2.0
File Size Uploaded Provenance Actions
huawei_solar-3.2.0.tar.gz 209.5 kB With provenance Details for huawei_solar-3.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for huawei-solar 3.2.0
File Interpreter ABI Platform Actions
huawei_solar-3.2.0-py3-none-any.whl Python 3 none any Details for huawei_solar-3.2.0-py3-none-any.whl

Total release size: 330.4 kB

Release files / huawei_solar-3.2.0.tar.gz

Download URL huawei_solar-3.2.0.tar.gz
Size 209.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ae5a5b1e6475c9d9c810639ea98eade9699d30d61594b0aea3bf60330e3e4955
BLAKE2b-256 checksum
How to use checksums
257ac4b781e0b8f41d4fe665cb1379fcec5a80a0b6adb2f3fcc710af52da041b
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 Nov 20, 2026.

Transparency log

Release files / huawei_solar-3.2.0-py3-none-any.whl

Download URL huawei_solar-3.2.0-py3-none-any.whl
Size 120.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ba813cf748968dd6993ae3e5ae8698f2a8e29ea15572c3eaf3161498d5afdb2
BLAKE2b-256 checksum
How to use checksums
62bb8b93341dec63face23bea80cbe2fcac610e20061fc0bd4b9800de57edb11
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 Nov 20, 2026.

Transparency log

Security for huawei-solar 3.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for huawei_solar-3.2.0.tar.gz

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 Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.2.0 This release

2 release files Full provenance

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