A Python library for interacting with Huawei solar inverters, batteries, power meters, and EMI devices via Modbus TCP.
Project description
Huawei Solar Tools
Huawei Solar Tools is a Python library for interacting with Huawei solar inverters, batteries, power meters, and energy management interfaces (EMI) using Modbus TCP.
It provides methods to read and write Modbus registers, retrieve operational data, and interpret register values.
Functionality
- Establishes Modbus TCP communication with Huawei solar devices.
- Reads and writes Modbus registers.
- Retrieves device status, operational parameters, and alarms.
- Converts raw register values into structured data.
- Supports multiple devices in parallel.
Target Users
- Developers integrating Huawei solar devices into software systems.
- System administrators managing solar installations.
- Data engineers handling time-series data from Huawei devices.
Features
📡 Communication
- Modbus TCP client for interacting with Huawei solar equipment.
- Multi-device support.
🔍 Data Retrieval
- Reads real-time data from inverters, batteries, and meters.
- Fetches system status, alarms, and operational parameters.
- Reads raw registers and interprets their values.
🔧 Register Processing
- Decodes bitfields, integers, floats, and string registers.
- Converts raw Modbus register values into structured formats.
📊 Database Integration (User Implementation)
- Compatible with ClickHouse and InfluxDB for data storage (not required for core library).
Installation
Huawei Solar Tools requires Python 3.9+.
Install via PyPI:
pip install huawei-solar-tools
Install from source:
git clone https://github.com/atrabilis/huawei-solar-tools.git
cd huawei-solar-tools
pip install .
Usage
The following examples demonstrate how to use the Huawei Solar Tools library for basic interactions.
For more detailed examples, refer to the scripts in the tests/ directory.
1️⃣ Initialize a Connection to a Huawei Inverter
from huawei_solar_tools.devices.inverter import Inverter
# Define connection parameters
host = "192.168.1.100"
port = 502
device_id = 1
# Initialize the inverter
inverter = Inverter(host, port, device_id)
async def main():
await inverter.connect()
print(f"Device ID: {inverter.get_device_id()}")
print("All Registers:", await inverter.read_all_registers())
await inverter.disconnect()
import asyncio
asyncio.run(main())
Supported Devices and Compatibility
Huawei Solar Tools is designed to interact with the following Huawei solar devices via the Modbus TCP protocol. Compatibility is based on the firmware and device models specified in the Huawei Modbus documentation.
1️⃣ Inverters
- Supported Models: SUN2000 Series
- Example Models: SUN2000-33KTL, SUN2000-60KTL, SUN2000-100KTL
- Firmware Requirements: V100R001C00SPC200 or later
2️⃣ Batteries
- Supported Models:
- LUNA2000: LUNA2000-5, LUNA2000-10
- LG-RESU: LG-RESU10H
- Firmware Requirements: V200R002C10SPC100 or later
3️⃣ Power Meters
- Supported Models:
- DDSU666-H
- DTSU666-H
- Features:
- Measures phase voltages, currents, active/reactive power, and total energy.
- Registers include power factor, phase-by-phase power, and total energy consumption.
4️⃣ Energy Management Interfaces (EMI)
- Supported Features:
- Environmental monitoring (wind speed, wind direction, temperature, irradiance).
- Supports data logging and integration with Huawei SmartLogger.
- Firmware Requirements: V200R002C20 or later
5️⃣ SmartLogger
- Supported Models:
- SmartLogger3000
- SmartLogger2000
- Firmware Requirements: V100R001C00 or later
- Features:
- Supports data collection and communication with multiple Huawei devices.
- Provides power control, alarm management, and device synchronization via Modbus.
References
- Huawei Technologies Co., Ltd. SmartLogger Modbus Interface Definitions, Issue 35. 2020. Proprietary documentation.
- Huawei Technologies Co., Ltd. Solar Inverter Modbus Interface Definitions, Issue 5. 2020. Proprietary documentation.
Contributing
Contributions to Huawei Solar Tools are welcome! Follow the steps below to contribute to the project:
| Step | Description | Commands/Details |
|---|---|---|
| 1. Fork | Create a personal copy of the repository. | Click the Fork button on the repository's GitHub page. |
| 2. Clone | Clone the forked repository to your local machine. | bash<br>git clone https://github.com/YOUR_USERNAME/huawei-solar-tools.git<br>cd huawei-solar-tools<br> |
| 3. Branch | Create a new branch for your changes. | bash<br>git checkout -b feature-new-functionality<br> |
| 4. Develop | Make your changes following the current structure and conventions of the codebase. | - Keep your code readable and consistent. - Add docstrings where appropriate to explain functionality. |
| 5. Test (if applicable) | Verify your changes using the provided test scripts in the tests/ directory or you can make your own less ad hoc more proffesional tests. |
bash<br>python tests/test_inverter.py<br> |
| 6. Commit | Stage and commit your changes with a descriptive message. | bash<br>git add .<br>git commit -m "Add new functionality for inverters"<br> |
| 7. Push | Push your changes to your forked repository. | bash<br>git push origin feature-new-functionality<br> |
| 8. Pull Request | Open a pull request to the main repository. | Provide a clear description of your changes and their purpose. |
For questions or clarifications, feel free to open an issue.
License
This project is licensed under the MIT License. You are free to use, modify, and distribute this software, provided that the original copyright notice and permission notice are included in all copies or substantial portions of the software.
For detailed licensing information, refer to the LICENSE file in the repository.
Future Work
A lot of improvements and features are planned for Huawei Solar Tools like optimizers reading and write operations. A detailed roadmap will be posted in the future.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file huawei_solar_tools-0.1.5.tar.gz.
File metadata
- Download URL: huawei_solar_tools-0.1.5.tar.gz
- Upload date:
- Size: 34.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47dfdfbcfeae2512ef704f911ad60544f282f85f7873bde9e9e56535e342fd48
|
|
| MD5 |
35c81d2267fa8c7adc83762e064dc98d
|
|
| BLAKE2b-256 |
f76cfb0ff3eb45bef5555310e29efd4c76bb7a6d73fea4172b8bd495cd612635
|
File details
Details for the file huawei_solar_tools-0.1.5-py3-none-any.whl.
File metadata
- Download URL: huawei_solar_tools-0.1.5-py3-none-any.whl
- Upload date:
- Size: 45.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
775bcb4efea82ac80a8d5eb488bccc4f7d34b026bc1b72bd6140682172146dc0
|
|
| MD5 |
f1d501206ed1d66a45cda5a571bd406a
|
|
| BLAKE2b-256 |
3f100acf482ab6a9e291c3b963849d7cafeef22c9a3c75dad8166a6350689eca
|