{"id":46257409,"url":"https://github.com/wlcrs/huawei-solar-lib","last_synced_at":"2026-04-03T08:04:08.723Z","repository":{"id":105112812,"uuid":"568047175","full_name":"wlcrs/huawei-solar-lib","owner":"wlcrs","description":"Python library for communicating with Huawei SUN2000 inverters","archived":false,"fork":false,"pushed_at":"2026-03-01T12:58:49.000Z","size":507,"stargazers_count":41,"open_issues_count":0,"forks_count":23,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2026-03-01T16:18:00.485Z","etag":null,"topics":["energy-monitor","huawei","huawei-sun2000","python","sun2000"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wlcrs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"wlcrs"}},"created_at":"2022-11-19T09:29:49.000Z","updated_at":"2026-03-01T12:58:54.000Z","dependencies_parsed_at":"2023-12-02T08:25:14.522Z","dependency_job_id":"5db76a3f-a8dc-449d-8ff5-33a914514cfb","html_url":"https://github.com/wlcrs/huawei-solar-lib","commit_stats":null,"previous_names":[],"tags_count":124,"template":false,"template_full_name":null,"purl":"pkg:github/wlcrs/huawei-solar-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlcrs%2Fhuawei-solar-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlcrs%2Fhuawei-solar-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlcrs%2Fhuawei-solar-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlcrs%2Fhuawei-solar-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wlcrs","download_url":"https://codeload.github.com/wlcrs/huawei-solar-lib/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlcrs%2Fhuawei-solar-lib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30065859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T18:21:05.932Z","status":"ssl_error","status_checked_at":"2026-03-03T18:20:59.341Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["energy-monitor","huawei","huawei-sun2000","python","sun2000"],"created_at":"2026-03-03T23:34:22.631Z","updated_at":"2026-04-03T08:04:08.718Z","avatar_url":"https://github.com/wlcrs.png","language":"Python","funding_links":["https://github.com/sponsors/wlcrs"],"categories":[],"sub_categories":[],"readme":"[![Homepage](https://img.shields.io/badge/Homepage-2088ff?logo=github\u0026logoColor=white)](https://github.com/wlcrs/huawei-solar-lib)\n[![GitHub License](https://img.shields.io/github/license/wlcrs/huawei-solar-lib)](https://github.com/wlcrs/huawei-solar-lib/blob/main/LICENSE)\n[![Release](https://img.shields.io/github/v/release/wlcrs/huawei-solar-lib.svg)](https://github.com/wlcrs/huawei-solar-lib/releases)\n[![Python Versions](https://img.shields.io/pypi/pyversions/huawei-solar)](https://pypi.org/p/huawei-solar/)\n[![Testing](https://github.com/wlcrs/huawei-solar-lib/actions/workflows/tests.yml/badge.svg)](https://github.com/wlcrs/huawei-solar-lib/actions/workflows/tests.yml)\n\n\n# Python library for connecting to Huawei SUN2000 Inverters over Modbus\n\nThis library implements an easy to use interface to locally connect to Huawei Solar devices over\nModbus-TCP or Modbus-RTU following the 'Solar Inverter Modbus Interface Definitions' provided by Huawei.\n\nIt was primarily developed to add support for Huawei Solar inverters to Home Assistant, resulting\nin the following integration: [wlcrs/huawei_solar](https://github.com/wlcrs/huawei_solar).\n\n**Supported devices:**\n- SUN2000 inverters\n- LUNA2000 batteries (when connected to SUN2000)\n- EMMA\n- SCharger (when connected to EMMA)\n\n**Features:**\n\n- Modbus-TCP support: connecting to the inverter via the SDongle, EMMA, or over the WiFi-AP (`SUN2000-\u003cserial_no\u003e`)\n  broadcasted by the inverter\n- Modbus-RTU support: connecting to the inverter via the RS485A1 and RS485B1 pins on the COM port\n- Batched reading of Modbus registers and converting them into the correct units\n- Reading Optimizer data via the specialized 'file' Modbus extension\n- Writing to Modbus registers (mostly useful for setting battery parameters)\n- Performing the login sequence to gain 'installer'-level access rights\n\n## Installation\n\nThis library is [published on PyPI](https://pypi.org/project/huawei-solar/).\n\n\n## Basic usage\n\nThe library consists out of a low level interface implemented in [modbus_client.py](src/huawei_solar/modbus_client.py) which implements all the Modbus-operations, and a high level interface in [huawei_solar/devices](src/huawei_solar/devices.py) which facilitates easy usage (primarily meant for the HA integration).\n\n### Using the high level 'Devices' interface\n\nAn example on how to read the most interesting registers from the inverter:\n\n```py\nimport asyncio\n\nfrom huawei_solar import (\n    SUN2000Device,\n    create_device_instance,\n    create_tcp_client,\n)\nfrom huawei_solar import register_names as rn\n\nasync def test() -\u003e None:\n    \"\"\"Run test.\"\"\"\n    client = create_tcp_client(host=\"192.168.1.1\", port=503)\n    device = await create_device_instance(client)\n\n    assert isinstance(device, SUN2000Device)\n    print(\n        await device.batch_update(\n            [\n              rn.INPUT_POWER,\n              rn.LINE_VOLTAGE_A_B,\n              rn.LINE_VOLTAGE_B_C,\n              rn.LINE_VOLTAGE_C_A,\n            ]\n        ),\n    )\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\nThis results in the following output being printed:\n\n```\n{'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')}\n```\n\n## Frequently asked questions\n\n**Q:** the connection is interrupted a few seconds after connecting to the Huawei Device. How do I solve this?\n\n**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.\n\n## Acknowledgements\n\nThe initial implementation of v1 was done by [@Emilv2](https://gitlab.com/Emilv2/huawei-solar/-/tree/1.1.0).\n\nSubsequent development on v2 was done by [@wlcrs](https://github.com/wlcrs/huawei_solar).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwlcrs%2Fhuawei-solar-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwlcrs%2Fhuawei-solar-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwlcrs%2Fhuawei-solar-lib/lists"}