Skip to main content

fronius-modbus

Async Python library for the Modbus TCP (SunSpec) interface of Fronius inverters, built on modbus-connection.

Supports both Fronius device generations:

  • GEN24 / Tauro — the inverter itself serves Modbus TCP (unit ID 1)
  • SnapINverter via Datamanager 2.0 — the Datamanager gateways all inverters of a Fronius Solar Net ring (unit ID = inverter number, 00 → 100)

The SunSpec register map of Fronius devices is dynamic: model addresses shift with the configured data type (float vs int + SF) and differ between generations. This library discovers the model chain at runtime, so no register configuration is needed — and the data type setting is detected automatically.

Reading

  • SunSpec Common Model (1): manufacturer, model, software version and serial number.
  • SunSpec inverter models (101-103 / 111-113) in both encodings: AC power, frequency, lifetime energy, per-phase currents and voltages, apparent/reactive power, power factor, DC totals, operating state and vendor state, typed event flags.
  • SunSpec Multiple MPPT Inverter Extension Model (160): DC current, voltage, power and lifetime energy per MPP tracker, with module role classification (PV string / storage charge / storage discharge) and derived totals (PV-only energy, battery charging/discharging energy).
  • SunSpec Basic Settings Model (121): the inverter's nominal maximum power output, which the output power limit is a percentage of.
  • SunSpec Measurements Status Model (122): lifetime AC-side energy and whether a fixed output power limit is being applied.
  • SunSpec Basic Storage Control Model (124): state of charge, battery status, charge and discharge limits with their enable flags, minimum reserve and grid charging.

Each model is refreshed in as few pooled block requests as possible, and values are read together with their scale factors so the two can never disagree.

Writing

Write commands require inverter control via Modbus to be enabled on the device web interface; Controls.probe_write_access() reports whether the device accepts writes at all.

  • Immediate Controls (123): set_power_limit() and clear_power_limit() to limit the inverter output power.
  • Basic Storage Control (124): set_limits() for the battery charge and discharge rates (including forced charging), plus set_minimum_reserve() and set_grid_charging().

The limit setters take a revert_seconds auto-revert, so a controller that dies cannot leave the inverter constrained. Only writing a limit again restarts its period: Fronius documents every received Modbus message as restarting it, but a GEN24 drops the limit on time while being read (measured with scripts/check_storage_revert.py). A controller that keeps a limit in force calls Controls.refresh_power_limit() / Storage.refresh_limits() well before the period is up; they send the active limits again and report whether any was in force, so a limit released on the device is left released.

Usage

The library only consumes a ModbusUnit — connection lifecycle stays with the caller (or with Home Assistant's modbus_connection integration):

import asyncio

from fronius_modbus import FroniusModbusInverter, GEN24_UNIT_ID
from modbus_connection.tmodbus import connect_tcp


async def main() -> None:
    connection = await connect_tcp("192.168.1.50", port=502)
    inverter = FroniusModbusInverter(connection.for_unit(GEN24_UNIT_ID))
    await inverter.discover()
    print("Data type:", "float" if inverter.float_mode else "int+SF")
    print("Storage:", inverter.has_storage)  # auto-detected during discovery

    # one pooled read refreshes every discovered model
    await inverter.async_update()

    if (identity := inverter.common) is not None:
        print(identity.manufacturer, identity.model, identity.serial_number)

    if (ac_dc := inverter.inverter) is not None:
        print("AC power:", ac_dc.ac_power, "state:", ac_dc.operating_state)

    if (mppt := inverter.mppt) is not None:
        for module, role in zip(mppt.modules, mppt.module_roles, strict=True):
            print(module.id_str, role, module.power)
        print("PV energy total:", mppt.pv_energy_total)
        print("Battery charged:", mppt.storage_charge_energy_total)
        print("Battery discharged:", mppt.storage_discharge_energy_total)

    if (storage := inverter.storage) is not None:
        print("SoC:", storage.state_of_charge, "state:", storage.state)
        await storage.set_limits(charge=50.0, revert_seconds=60)

    await connection.close()


asyncio.run(main())

Modbus must be enabled on the inverter web interface (GEN24: Communication → Modbus → Slave as Modbus TCP; Datamanager: Settings → Modbus → Data output via Modbus → TCP).

Testing on real hardware

Two scripts in scripts/ help test the library against an inverter (clone the repo and run them with uv):

read_inverter.py — a one-shot dump of everything the library reads, plus optional write commands. Good for quick checks and scripting:

uv run scripts/read_inverter.py <inverter-ip>
uv run scripts/read_inverter.py <inverter-ip> --set-power-limit 80 --revert 60
uv run scripts/read_inverter.py <inverter-ip> --probe-write

monitor.py — an interactive terminal UI that polls live at a configurable interval. It shows the data panels and a status log, a live power graph with a selectable series list (AC power, per-MPPT and battery charge/discharge), and a write-command dialog (press s) for running every write command with immediate status feedback:

uv run scripts/monitor.py <inverter-ip> --interval 2

check_storage_revert.py — probes how the inverter handles the battery limit auto-revert: whether the period is honoured at all, and whether reads or only writes restart it. Behaviour-neutral (it enables the charge limit at 100 %) and restores what it found; about five minutes with the default period:

uv run scripts/check_storage_revert.py <inverter-ip> --period 60

Write commands require "inverter control via Modbus" to be enabled on the device web interface. Limit writes default to a 60 second auto-revert as a safety net.

Testing support

fronius_modbus.testing provides build_sunspec_map() to build SunSpec register maps for modbus_connection.mock.MockModbusUnit:

from fronius_modbus.testing import MpptModuleSpec, build_sunspec_map
from modbus_connection.mock import MockModbusConnection

connection = MockModbusConnection()
connection.for_unit(1).holding.update(
    build_sunspec_map(
        [MpptModuleSpec(id_str="String 1", current=82, voltage=4021, power=3300)],
        float_mode=True,
    )
)

License

GPL-3.0-or-later, see LICENSE.

Disclaimer

This is an unofficial library, not affiliated with Fronius International GmbH. Based on the public Fronius Modbus TCP & RTU operating instructions and the Fronius SunSpec register maps (fronius.com/QR-link/0006).

Metadata

Release files for fronius-modbus 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fronius-modbus 0.4.0
File Size Uploaded Provenance Actions
fronius_modbus-0.4.0.tar.gz 28.1 kB With provenance Details for fronius_modbus-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fronius-modbus 0.4.0
File Interpreter ABI Platform Actions
fronius_modbus-0.4.0-py3-none-any.whl Python 3 none any Details for fronius_modbus-0.4.0-py3-none-any.whl

Total release size: 60.9 kB

Release files / fronius_modbus-0.4.0.tar.gz

Download URL fronius_modbus-0.4.0.tar.gz
Size 28.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8604af5cb406eede9526cbf10fa1d21f43e73499ea3b5ebc3e9895693f584d77
BLAKE2b-256 checksum
How to use checksums
32ca952f79e67c8cac7ff6da1ee80124fcaa982d05bc276115113665bc3f980f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / fronius_modbus-0.4.0-py3-none-any.whl

Download URL fronius_modbus-0.4.0-py3-none-any.whl
Size 32.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
80457256b0f9872c49185718677ffcfd77966981f724a92bce33c5cb546f73a4
BLAKE2b-256 checksum
How to use checksums
d652baab2fdad0b378eab7840e472125effb4d1f1306ffd12f1b18cd7f75bfed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Security for fronius-modbus 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fronius_modbus-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page