Skip to main content

Asynchronous Python client for SolarEdge inverters over Modbus.

Project description

Python: Asynchronous client for SolarEdge over Modbus

GitHub Release Python Versions Project Stage Project Maintenance License

Build Status Code Coverage OpenSSF Scorecard Open in Dev Containers

Sponsor Frenck via GitHub Sponsors

Support Frenck on Patreon

Asynchronous Python client for SolarEdge inverters over Modbus.

About

This package reads and controls SolarEdge inverters, meters and batteries over Modbus, using the SunSpec register model. It is built for use inside Home Assistant, following the shared-connection approach described in the Modernizing Modbus developer blog.

It is built on top of modbus-connection, a backend-neutral async Modbus toolkit. The library does not own the connection: the consumer opens a ModbusConnection and hands over a ModbusUnit. A site with several inverters creates one SolarEdge per unit, all sharing a single connection.

Because the caller owns the connection, the transport is up to you. Modbus TCP over Ethernet or WiFi is the common path, but the library works just as well over RS485/RTU or an RTU-to-TCP gateway (such as an Elfin-EW11). Anything that hands it a ModbusUnit will do; the register map does not care how the bytes arrive.

Supported out of the box:

  • Inverter: power, energy, per-phase voltage/current, frequency, DC, temperatures, status, grid on/off, vendor status
  • Per-string DC (multiple-MPPT / SunSpec 160): current, voltage, power, energy, temperature per module
  • Up to three meters: power, per-phase measurements, imported/exported energy, apparent (VAh) and reactive (varh) energy
  • Batteries: state of energy/health, power, temperatures, status
  • Control blocks: storage control, export/site limit + external production, dynamic power control, advanced/reactive power control
  • EV charger detection (identity only; SolarEdge exposes no charger telemetry over Modbus)

Enabling Modbus TCP on your inverter

Modbus TCP is off by default. Enable it once on the inverter, then point this library at the inverter's IP address on port 1502.

Inverters with a display (older LCD models):

  1. Long-press OK (the rightmost button) to enter the menu.
  2. Enter the password by pressing Up, Down, OK, Up, Down, OK, Up, Down (12312312).
  3. Go to Communication, select LAN, and enable Modbus TCP.

Inverters set up with SetApp (no display): open the SetApp interface (join the inverter's WiFi access point and browse to http://172.16.0.1, or use the SetApp mobile app), then under Site Communication enable Modbus (TCP).

SolarEdge may drop WiFi-based Modbus in future firmware, so a wired Ethernet connection is the more reliable choice. Instructions adapted from the community home-assistant-solaredge-modbus project.

Installation

pip install solaredged

To install with the optional CLI, which drives the tmodbus backend:

pip install "solaredged[cli,tmodbus]"

As a library, solaredged talks to a ModbusUnit; pick a backend with the matching extra, solaredged[pymodbus] or solaredged[tmodbus], or let your application supply one.

Usage

The consumer owns the connection and hands the library a unit. The example below uses the tmodbus backend, so install it with pip install "solaredged[tmodbus]" first:

import asyncio

from modbus_connection.tmodbus import connect_tcp

from solaredged import SolarEdge


async def main() -> None:
    connection = await connect_tcp("solaredge.local", port=1502)
    try:
        unit = connection.for_unit(1)
        solaredge = await SolarEdge.async_probe(unit)  # detects the layout
        await solaredge.async_update()                 # one pooled read

        print(solaredge.inverter.ac_power, "W")
        print(solaredge.inverter.status)
        for battery in solaredge.batteries:
            print(battery.state_of_energy, "%")
    finally:
        await connection.close()


asyncio.run(main())

async_probe validates the SunSpec header and detects which meters, batteries and control blocks are present, plus whether the firmware serves the grid status extension (not all firmware does). async_update refreshes every component in as few Modbus reads as possible. Values decode to None when the device reports a point as not implemented, including a lifetime energy of 0 (SunSpec's "not accumulated", transiently reported by some firmware around sleep/wake). on_grid is None on firmware without the extension, and a battery state of energy or health outside 0-100 (reported by initializing batteries) decodes to None as well.

See the examples directory for more.

CLI

The optional CLI reads your inverter straight from the terminal. --host, --port and --unit can also be set via the SOLAREDGED_HOST, SOLAREDGED_PORT and SOLAREDGED_UNIT environment variables.

# Launch the live TUI dashboard
solaredged --host solaredge.local

# Show a one-shot reading
solaredged info --host solaredge.local

# Machine-readable output
solaredged info --host solaredge.local --json

# Dump the raw register map (handy for debugging and fixtures)
solaredged dump --host solaredge.local

Control commands write to the inverter, so only use them on hardware you own. Each one asks for confirmation before writing; pass --yes (or -y) to skip the prompt in scripts.

# Limit active power output to a percentage of nominal
solaredged power-limit 80 --host solaredge.local

# Set the battery storage control mode
solaredged storage-mode MAXIMIZE_SELF_CONSUMPTION --host solaredge.local

# Set the power factor (cos phi) setpoint
solaredged cos-phi 0.95 --host solaredge.local

# Battery: reserve, charge policy, and remote charge/discharge
solaredged backup-reserve 20 --host solaredge.local
solaredged charge-policy ALWAYS --host solaredge.local
solaredged remote-charge 3000 --timeout 1800 --host solaredge.local
solaredged remote-discharge 4000 --host solaredge.local

# Skip the confirmation prompt (for scripting)
solaredged power-limit 80 --host solaredge.local --yes

More controls (export mode/limit, external production, advanced/reactive power control, commit/restore) are available through the library API on the storage_control, export_control, power_control and advanced_power_control components.

Changelog & releases

This repository keeps a change log using GitHub's releases functionality. Releases are based on Semantic Versioning, and use the format of MAJOR.MINOR.PATCH.

Contributing

Contributions are welcome. See CONTRIBUTING.md for how to get started and what the review expects.

Setting up development environment

The easiest way to start, is by opening a CodeSpace here on GitHub, or by using the Dev Container feature of Visual Studio Code.

Open in Dev Containers

This Python project is fully managed using the Poetry dependency manager, and relies on NodeJS for some of the checks during development.

You need at least:

  • Python 3.12+
  • Poetry
  • NodeJS 24+ (including NPM)

To install all packages, including all development requirements:

npm install
poetry install

As this repository uses the prek framework, all changes are linted and tested with each commit. You can run all checks and tests manually, using the following command:

poetry run prek run --all-files

To run just the Python tests:

poetry run pytest

Authors & contributors

The original setup of this repository is by Franck Nijhof.

For a full list of all authors and contributors, check the contributor's page.

Disclaimer

This project is an independent, community-driven effort. It is not affiliated with, endorsed by, or supported by SolarEdge Technologies. All product names, trademarks, and registered trademarks are property of their respective owners.

The register map is based on SolarEdge's publicly documented SunSpec implementation and the excellent solaredge-modbus-multi community integration. This work is done for interoperability purposes.

Use this software at your own risk. The authors are not responsible for any damage to your equipment, property, or person resulting from the use of this library. Writing control registers changes how your inverter and battery behave; only do so on hardware you own and understand.

License

MIT License

Copyright (c) 2026 Franck Nijhof

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

solaredged-0.2.0.tar.gz (37.3 kB view details)

Uploaded Source

Built Distribution

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

solaredged-0.2.0-py3-none-any.whl (37.8 kB view details)

Uploaded Python 3

File details

Details for the file solaredged-0.2.0.tar.gz.

File metadata

  • Download URL: solaredged-0.2.0.tar.gz
  • Upload date:
  • Size: 37.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for solaredged-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e0d5e3e4087ce0d0205b610521fb1d0a3550949b5c217ca7880636f9e02b08af
MD5 fd108cb33f400cf2473082d83c118f02
BLAKE2b-256 efb433472baccfda975b6d6821610a862e564228774d41a888819297cb427a5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for solaredged-0.2.0.tar.gz:

Publisher: release.yaml on frenck/python-solaredged

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file solaredged-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: solaredged-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 37.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for solaredged-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd297cf4940de7d4a384b9246e97b44288899304ab2495c3d534a3a4418d4c16
MD5 c5826caa669d5fb42ad838f33aba0f07
BLAKE2b-256 dcc6f19e7d27344052d3f8ef72cf14e39c1d23e829073acdec630d1881d641af

See more details on using hashes here.

Provenance

The following attestation bundles were made for solaredged-0.2.0-py3-none-any.whl:

Publisher: release.yaml on frenck/python-solaredged

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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