Add ZHA support for the Amina S charger#91
Open
attaxia wants to merge 4 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
AminaChargeris an MQTT implementation:is_charger_device()required themqttidentifier domain + azigbee2mqttprefix.{integration: "mqtt", manufacturer: "Amina Distribution AS"}.A ZHA device has identifier domain
zhaand is driven through Home Assistant entities exposed bythe quirk, not MQTT topics — so it was invisible to both.
What changed
AminaZhaCharger(chargers/amina_zha_charger.py), an entity-based charger modeled onthe 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 thestandard ZHA OnOff switch (via its
-10-6unique-id suffix) to pause below the 6 A hardware minimum.CHARGER_DOMAIN_ZHA+CHARGER_MANUFACTURER_AMINA_ZHAinconst.py, added tocharger_factory, and added to the config-flow device filter (both the lowercase manufacturerstring real units report and the capitalised spec form).
AminaChargeris untouched.Reviewer notes
get_current_limit()reports the limit uniformly across all phases and tracks pause state with aninternal flag. An earlier iteration returned
{L1: limit, L2: 0, L3: 0}in single-phase mode, whichmade the allocator's
min()-based change detection always see 0 and never adjust the limit — fixed here.tests/chargers/test_amina_zha_charger.py;ruff check/formatclean.