{"id":21445,"library":"huawei-solar","title":"Huawei Solar","description":"A Python wrapper for the Huawei Inverter Modbus TCP API. Current version is 3.0.0 (stable), released 2024. Releases are semi-regular. The v3 major release introduced breaking changes, including migration from pyModbus to tModbus, renaming of \"bridge\" classes to \"device\" classes, and replacement of `slave_id` with `unit_id`.","status":"active","version":"3.0.0","language":"python","source_language":"en","source_url":"https://github.com/wlcrs/huawei-solar-lib","tags":["huawei","solar","inverter","modbus","tcp","asyncio"],"install":[{"cmd":"pip install huawei-solar","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Required for Modbus communication since v3","package":"tmodbus","optional":false},{"reason":"Required for serial connection (optional, for SunSpec)","package":"pyserial-asyncio","optional":true}],"imports":[{"note":"In v2 the class was in huawei_solar.bridge; v3 moved it to top-level.","wrong":"from huawei_solar.bridge import HuaweiSolarBridge","symbol":"HuaweiSolarBridge","correct":"from huawei_solar import HuaweiSolarBridge"},{"note":"v3 renamed bridge classes to device classes (e.g., HuaweiSun2000), but bridge is an alias kept for backward compatibility.","wrong":"from huawei_solar.devices import HuaweiSolarBridge","symbol":"HuaweiSolarBridge","correct":"from huawei_solar import HuaweiSolarBridge"},{"note":"The new device class for v3; replaces HuaweiSolarBridge for most use cases.","wrong":"","symbol":"HuaweiSun2000","correct":"from huawei_solar import HuaweiSun2000"}],"quickstart":{"code":"import asyncio\nfrom huawei_solar import HuaweiSun2000\n\nasync def main():\n    # Connect over TCP\n    inverter = HuaweiSun2000(host='192.168.1.100', port=502)\n    await inverter.start()\n    # Read a register, e.g., 'input_power'\n    result = await inverter.read('input_power')\n    print(f'Input power: {result.value} W')\n    await inverter.stop()\n\nasyncio.run(main())","lang":"python","description":"Connects to a Huawei inverter over TCP and reads a register."},"warnings":[{"fix":"Change `slave_id=1` to `unit_id=1` when instantiating HuaweiSun2000.","message":"v3 migration: `slave_id` parameter replaced with `unit_id` in all device classes.","severity":"breaking","affected_versions":"<3.0.0"},{"fix":"Always use `await` when calling methods like `read()`, `write()`, `start()`, `stop()`.","message":"The library uses asyncio; all read/write operations must be awaited. Forgetting `await` will hang the coroutine.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Replace `HuaweiSolarBridge` with the appropriate device class depending on the hardware.","message":"The class `HuaweiSolarBridge` is deprecated in v3; use `HuaweiSun2000` (or `HuaweiSmartLogger`, `HuaweiSCharger`, `HuaweiSdongle`) instead.","severity":"deprecated","affected_versions":"3.0.0"},{"fix":"Check the device's capabilities via `inverter.capabilities` attribute.","message":"When connecting via SmartLogger, not all registers are available (e.g., capacity control mode).","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Upgrade to v3 and import `HuaweiSun2000`: `from huawei_solar import HuaweiSun2000`","cause":"The class is no longer at top-level in v3, or you installed v3 but expect v2 API.","error":"ImportError: cannot import name 'HuaweiSolarBridge' from 'huawei_solar'"},{"fix":"Use `await inverter.read(['register1', 'register2'])` instead.","cause":"The method `read_batch` was renamed to `read` (which accepts multiple registers) or removed in v3.","error":"AttributeError: 'HuaweiSun2000' object has no attribute 'read_batch'"},{"fix":"Use `unit_id=1` instead of `slave_id=1`.","cause":"In v3, `slave_id` was renamed to `unit_id`.","error":"TypeError: __init__() got an unexpected keyword argument 'slave_id'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}