Skip to main content

apsystems2mqtt

Reads output metrics, operating state, and alarms from an APsystems EZ1-M microinverter's local REST API and publishes them to MQTT periodically. Optionally subscribes to a topic to control the inverter's max power limit.

Usage

uv run apsystems2mqtt run --inverter_host 192.168.1.50 --mqtt_hostname mqtt.local

Published topics (under --topic_prefix, default apsystems2mqtt):

  • <prefix>/output - power/energy readings (p1, e1, te1, p2, e2, te2, totals)
  • <prefix>/state - {"online": bool, "powered_on": bool} (powered_on omitted while offline)
  • <prefix>/alarm - off-grid and short-circuit alarm flags

The inverter powers itself off at night when there's no sunlight, and stops responding to requests. This is expected: the CLI publishes {"online": false} to <prefix>/state and keeps retrying on every poll, but only logs a warning the first time it goes offline and then once every 6 hours while it stays offline, followed by a single info log once it comes back.

With --enable_power_control, the CLI also subscribes to <prefix>/max_power/set (plain integer watts payload) and applies the value to the inverter:

  • Values below the inverter's minimum (30W) turn the inverter off instead, since the device doesn't support setting a limit that low.
  • Values at or above the minimum turn the inverter on (if it wasn't already) and set the limit, publishing the confirmed value to <prefix>/max_power.
  • Since each change is written to the inverter's flash, applies are debounced: at most one apply every --max_power_update_interval seconds (default 300), using the most recently received value, and skipped entirely if it's unchanged from what was last applied.
  • With --max_power_limit, every requested limit is capped to that many watts before being applied - useful when the grid operator or local regulations cap allowed output below the device's own max_power (800W). This also lowers the Home Assistant number entity's slider max, when --homeassistant is used.
  • At startup, and again whenever the inverter comes back online after being offline, the CLI reads back the inverter's currently configured max power (getMaxPower) and publishes it to <prefix>/max_power - so consumers like Home Assistant's number entity show the actual current value instead of "Unknown" before the first change is made through this application.

With --homeassistant --homeassistant_device_id <id>, the CLI publishes Home Assistant MQTT discovery config for the inverter's output/energy readings and alarms as sensor/ binary_sensor entities, all pointing back at the existing <prefix>/output and <prefix>/alarm topics via value_template - no new telemetry topics are introduced. Entity availability is tied to <prefix>/state's online flag, so entities go unavailable in Home Assistant whenever the inverter is offline. If --enable_power_control is also set, a number entity (power limit) and a switch entity (on/off) are added as well, both writing to the existing <prefix>/max_power/set topic - the switch's ON/OFF payloads are translated to the last non-zero limit seen (or the inverter's max power if none yet) and 0 respectively. Discovery configs are published (retained) each time the CLI connects to the broker. Use --homeassistant_prefix to override Home Assistant's discovery topic prefix (default homeassistant).

To remove previously published discovery entities from Home Assistant, run uv run apsystems2mqtt clear-homeassistant with the same --topic_prefix/--enable_power_control/--homeassistant_device_id/ --homeassistant_prefix values used with run - it publishes an empty, retained message to each discovery config topic and exits.

Run uv run apsystems2mqtt run --help for all options, or uv run apsystems2mqtt generate-systemd (with the same flags as run) to print a systemd unit file for deployment.

Development

The project uses uv. Tests can for example be run with:

uv run pytest

Metadata

Release files for apsystems2mqtt 0.1.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 apsystems2mqtt 0.1.0
File Size Uploaded Provenance
apsystems2mqtt-0.1.0.tar.gz 12.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for apsystems2mqtt 0.1.0
File Interpreter ABI Platform
apsystems2mqtt-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.4 kB

Release files / apsystems2mqtt-0.1.0.tar.gz

Download URL apsystems2mqtt-0.1.0.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e531d50e15b95f6dc01aa94f273bd821574d33953644c29360bfa30688ef0549
BLAKE2b-256 checksum
How to use checksums
3d98a9216dcfc7484ac80e017db158abad4f223250646088ab902cb350f9ee65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / apsystems2mqtt-0.1.0-py3-none-any.whl

Download URL apsystems2mqtt-0.1.0-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7f3433b4fc0292cee4ef0f593e759a1295abc9b3721373acd2d74dca643dd80
BLAKE2b-256 checksum
How to use checksums
197d24f1f995b74abd581d9e645c8fc33ab911059b5553bf38772aa1c8bb06ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for apsystems2mqtt 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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