SolarEdge SunSpec Modbus reader/writer module and CLI
Project description
SolarEdge Modbus Module with MQTT sender/receiver
Python module and CLI for reading SolarEdge SunSpec Modbus data and writing setting registers when needed.
MQTT gateway documentation:
Implementation is based on the spec file in this repository:
sunspec-implementation-technical-note.pdf(Version 3.2, June 2025)
Supported model blocks:
- Common model block (base-0
40000) - Inverter model
101/102/103(base-040069) - Multiple MPPT model
160(base-040121)
Install
uv sync
CLI Usage
The CLI uses base-0 Modbus addresses, as in protocol address format.
Read common model over TCP:
uv run python main.py --transport tcp --host 192.168.1.50 --port 1502 --unit 1 read-common
Read inverter metrics:
uv run python main.py --transport tcp --host 192.168.1.50 --port 1502 --unit 1 read-inverter
Read MPPT extension model 160:
uv run python main.py --transport tcp --host 192.168.1.50 --port 1502 --unit 1 read-mppt
Read raw registers:
uv run python main.py --transport tcp --host 192.168.1.50 --port 1502 --unit 1 read-registers 40069 52
Write a single register (use carefully):
uv run python main.py --transport tcp --host 192.168.1.50 --port 1502 --unit 1 write-register 40068 2
Set C_DeviceAddress (valid range 1..247):
uv run python main.py --transport tcp --host 192.168.1.50 --port 1502 --unit 1 set-device-address 2
RTU example:
uv run python main.py --transport rtu --serial-port COM3 --baudrate 115200 --unit 1 read-inverter
Python Module Usage
from solaredgemodbus2mqtt.solaredge_modbus.client import SolarEdgeModbusClient
with SolarEdgeModbusClient.tcp("192.168.1.50", port=1502, timeout=3.0) as client:
common = client.read_common_model(unit=1)
inverter = client.read_inverter_data(unit=1)
print(common.to_dict())
print(inverter.to_dict())
# Optional write operation for supported setting registers.
# Example: set C_DeviceAddress
# client.set_device_address(new_unit_id=2, unit=1)
Notes
- Scale factors are applied to values according to SunSpec rules.
- Not-implemented values are returned as
Nonewhere relevant. - Write operations are available, but whether a specific register is writable depends on device firmware/configuration.
Pydantic Schemas
The package includes Pydantic models to validate and describe parsed data fields:
CommonModelSchemaInverterDataSchemaMpptUnitDataSchemaMpptModelDataSchema
Example:
from solaredgemodbus2mqtt.solaredge_modbus.client import SolarEdgeModbusClient
from solaredgemodbus2mqtt.solaredge_modbus.schemas import InverterDataSchema
with SolarEdgeModbusClient.tcp("192.168.1.50", port=1502) as client:
inverter = client.read_inverter_data(unit=1)
validated = InverterDataSchema.from_inverter_data(inverter)
print(validated.model_dump())
Testing
Install dev dependencies and run tests:
uv sync --group dev
uv run pytest -q
Test layout:
tests/test_parsing_unit.py: unit tests for low-level parsing and scale factor handlingtests/test_client_integration.py: integration-style parsing tests with mocked Modbus readstests/test_schemas.py: Pydantic validation tests
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 solaredgemodbus2mqtt-1.0.0.tar.gz.
File metadata
- Download URL: solaredgemodbus2mqtt-1.0.0.tar.gz
- Upload date:
- Size: 1.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f4e8b32c6ee46c697098b2d923c4e0ed423976e1134c4e87b4f089e4068b3d2
|
|
| MD5 |
eead911e3820f87b1677d639f15076bd
|
|
| BLAKE2b-256 |
24941a1bf404d72a7004c4170157aea4bdbdc497b844c2b8406d32b0f156ec11
|
File details
Details for the file solaredgemodbus2mqtt-1.0.0-py3-none-any.whl.
File metadata
- Download URL: solaredgemodbus2mqtt-1.0.0-py3-none-any.whl
- Upload date:
- Size: 28.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c01140bb1cf085a1db6a992ddf579d1f2398e5ad0dee15187c620e3b185398e3
|
|
| MD5 |
bad9e7f52eb93163c13f226730197534
|
|
| BLAKE2b-256 |
c318d65044de1999d631233fb67861bdfe410d807d4dc856d44dbc62f593acdf
|