Skip to content

Add ZHA support for the Amina S charger#91

Open
attaxia wants to merge 4 commits into
dirkgroenen:mainfrom
attaxia:feat/amina-s-zha-support
Open

Add ZHA support for the Amina S charger#91
attaxia wants to merge 4 commits into
dirkgroenen:mainfrom
attaxia:feat/amina-s-zha-support

Conversation

@attaxia
Copy link
Copy Markdown
Contributor

@attaxia attaxia commented Jun 5, 2026

What

Adds support for load-balancing an Amina S charger connected through ZHA (using the
attaxia/amina_s_zha_quirk). Previously only the
Zigbee2MQTT variant was supported, so a ZHA-connected Amina S never appeared in the config flow
and was never matched by the charger factory.

Why it didn't work before

The existing AminaCharger is an MQTT implementation:

  • is_charger_device() required the mqtt identifier domain + a zigbee2mqtt prefix.
  • The config-flow device filter only offered {integration: "mqtt", manufacturer: "Amina Distribution AS"}.

A ZHA device has identifier domain zha and is driven through Home Assistant entities exposed by
the quirk, not MQTT topics — so it was invisible to both.

What changed

  • New AminaZhaCharger (chargers/amina_zha_charger.py), an entity-based charger modeled on
    the Lektrico/Easee chargers. Resolves the quirk's entities by translation_key (charge_limit,
    hardware_current_limit, ev_connected, charging, ev_status, single_phase) and uses the
    standard ZHA OnOff switch (via its -10-6 unique-id suffix) to pause below the 6 A hardware minimum.
  • Registration: CHARGER_DOMAIN_ZHA + CHARGER_MANUFACTURER_AMINA_ZHA in const.py, added to
    charger_factory, and added to the config-flow device filter (both the lowercase manufacturer
    string real units report and the capitalised spec form).
  • The MQTT AminaCharger is untouched.

Reviewer notes

  • get_current_limit() reports the limit uniformly across all phases and tracks pause state with an
    internal flag. An earlier iteration returned {L1: limit, L2: 0, L3: 0} in single-phase mode, which
    made the allocator's min()-based change detection always see 0 and never adjust the limit — fixed here.
  • Tested with 30 unit tests in tests/chargers/test_amina_zha_charger.py; ruff check/format clean.

Out of scope for this PR, but surfaced during testing: conservative overcurrent mode never reduces
the charger limit (the balancer clamps computed availability at 0, and the allocator only cuts on
negative values). Optimised mode works correctly. Worth a separate fix.

attaxia and others added 4 commits May 13, 2026 15:08
Minor edit - updated the maintained icon for 2026 as there have been commits.
The existing AminaCharger only detects and drives the Amina S over
Zigbee2MQTT. A ZHA-connected Amina S (via the attaxia/amina_s_zha_quirk)
has identifier domain "zha" and is controlled through HA entities rather
than MQTT topics, so it was neither offered in the config flow nor
matched by the charger factory.

Add an entity-based AminaZhaCharger (modeled on the Lektrico/Easee
chargers) that resolves the quirk's entities by translation_key, uses
the standard ZHA OnOff switch to pause below the 6A hardware minimum,
and registers it in the factory and config-flow device filter. The MQTT
implementation is left untouched.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
get_current_limit() reported {L1: limit, L2: 0, L3: 0} in single-phase
mode. The PowerAllocator treats the Amina as a synced-phase charger and
only compares min() across phases, so the minimum was always 0 and a
limit change was never detected - the charge limit was never applied and
load balancing silently did nothing.

Report the limit uniformly across all phases instead, and track the
paused state internally (set when a sub-6A request switches the charger
off) rather than inferring "off -> 0A" from the OnOff switch state, which
was an additional way min() could get stuck at 0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant