Skip to main content

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-0 40069)
  • Multiple MPPT model 160 (base-0 40121)

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 None where 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:

  • CommonModelSchema
  • InverterDataSchema
  • MpptUnitDataSchema
  • MpptModelDataSchema

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 handling
  • tests/test_client_integration.py: integration-style parsing tests with mocked Modbus reads
  • tests/test_schemas.py: Pydantic validation tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solaredgemodbus2mqtt-1.1.0.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

solaredgemodbus2mqtt-1.1.0-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file solaredgemodbus2mqtt-1.1.0.tar.gz.

File metadata

  • Download URL: solaredgemodbus2mqtt-1.1.0.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","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

Hashes for solaredgemodbus2mqtt-1.1.0.tar.gz
Algorithm Hash digest
SHA256 66b3467b27efbc5dcba0ed8061e3190ba9e84ac861aafc283c86961578c6d217
MD5 7fbef624b685941c3f8438d6d1b7b51b
BLAKE2b-256 d4d11dcd1a6be3075f354b52fd37d3d398af009541b8ae7a8ea16b95a37f986d

See more details on using hashes here.

File details

Details for the file solaredgemodbus2mqtt-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: solaredgemodbus2mqtt-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","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

Hashes for solaredgemodbus2mqtt-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5abde74835916e5f0eeb60b6183b648b55526212034b6f5f25f574283d192973
MD5 a378d169f665217c9bb1b7f77f0b429c
BLAKE2b-256 df69de9d13f2b0922335c7a11d24db6f24e2dfa2f10f6535bda9c53c8d1d4bc5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page