Skip to content

fix(inverter): warn once about an eco toggle that cannot be written, and never write a non-switch through it (#4909) - #5647

Open
chalfontchubby wants to merge 3 commits into
mainfrom
fix/gecloud-no-eco-toggle-4909
Open

chalfontchubby wants to merge 3 commits into
mainfrom
fix/gecloud-no-eco-toggle-4909

Conversation

@chalfontchubby

Copy link
Copy Markdown
Collaborator

Posted by Claude on behalf of @chalfontchubby.

Fixes #4909.

Summary

GivEnergy 3-phase inverters have no eco mode register. GE Cloud's automatic config therefore creates no enable_eco_mode switch for them, but the GEC inverter type still sets has_ge_eco_toggle, so adjust_inverter_mode() kept trying to drive a switch that does not exist:

The bigger consequence in the report, Freeze Export silently not working on this hardware, was already fixed by #5542, which stops it being planned there.

Change

The eco-toggle entity is now checked at the top of adjust_inverter_mode(), before any write and before the 30s window-change sleep, which has nothing to wait for if nothing can be written:

Binding Write Log Status
switch.* / input_boolean.* as before as before as before
missing (incl. the empty slot GE Cloud leaves for a 3-phase unit in a mixed fleet) skipped one warning per inverter, noting it is expected on 3-phase none, since it is expected hardware behaviour
select, sensor, fixed value (e.g. YAML off) skipped one detailed warning with the fix a short status error on every call, since eco mode can then never be controlled

The detailed warning is repeated only if the problem changes, or if it comes back after a working switch. The warn-once state is set in __init__, not refresh_config(), which runs every cycle. Other inverter types are unchanged.

Behaviour changes worth knowing:

  • For a wrong binding in the force-export direction, the old code's false success recorded nothing; it now records the status error.
  • An explicitly empty inverter_mode slot used to be silent. It now gets the one-off warning, since that is the mixed-fleet 3-phase case.

Deliberately not done

  • Clearing has_ge_eco_toggle for these inverters. execute.py:904 also uses it to decide whether to enable scheduled discharge ahead of a GE export window, so clearing it would change export timing on hardware we can't test.
  • Driving a hand-mapped GivTCP mode select through write_and_poll_option ("Eco" / "Timed Export"). That would make the original 3phase GE Cloud: no enable_eco_mode switch (or anything eco/demand-mode related) is created. So inverter_mode slot is empty #4909 configuration work, but it is a design change: a GEC inverter driven like a GE one. The reporter has since moved to GE Cloud automatic config. Happy to add it if wanted.

Tests

  • New test_adjust_ge_eco_toggle_warns_once in test_inverter.py runs refresh_config() between cycles, as execute does. It covers:
    • a missing switch;
    • a select, a sensor, and the fixed values Eco and False;
    • a working input_boolean and a working switch;
    • re-warning after a working toggle;
    • status errors appearing only for wrong bindings;
    • no write ever reaching a refused binding;
    • the 30s sleep being skipped only when nothing can be written.
  • It fails on main.
  • Mutation checks: removing the warning reset fails the test, and so does letting a refused binding fall through to the write.
  • The two existing missing-entity cases for an explicit None now expect the one-off warning.
  • The TestHAInterface mock gains input_boolean/turn_on and turn_off.
  • ./run_all --quick passes. run_pre_commit passes (all 14 hooks).

Review

  • A cold subagent review found no bugs.
  • Eight rounds of local /code-review high. The last two found no correctness issues.
  • Findings declined:
    • Moving the check into check_write_entity or discovery-time flags (a refactor).
    • Allowing sensor (Predbat never creates a sensor stand-in for the eco toggle, and coordinator.py only sets has_ge_eco_toggle for a switch).
    • A pre-existing Out of range index warning for a short per-inverter inverter_mode list.

🤖 Generated with Claude Code

…and never write a non-switch through it (#4909)

GivEnergy 3-phase inverters have no eco mode register, so GE Cloud's
automatic config creates no enable_eco_mode switch, but the GEC type
still sets has_ge_eco_toggle. adjust_inverter_mode() then logged a mode
change and a "No entity_id for ECO Toggle" warning on every plan cycle.

With a mode select bound to inverter_mode instead (the original #4909
report, GivTCP's select mapped by hand), the switch path called the
non-existent select.turn_on ten times per attempt, and in the
force-export direction reported "No write needed" without writing,
because the select's state read back as a False switch.

The eco toggle entity is now checked before any write and before the
30s window-change sleep, which had nothing left to wait for:

- missing (no entity for this inverter, including the empty slot GE
  Cloud leaves for a 3-phase unit in a mixed fleet): skipped, and logged
  once per inverter, since it is expected on hardware without eco mode;
- anything other than a switch or input_boolean (a select, a sensor, a
  fixed value such as YAML "off"): skipped, with the detailed warning
  and fix logged once, and a short status error (which record_status
  also logs) on every call, since eco mode can then never be controlled.
  This is a change in the export direction, where the old code's false
  success recorded nothing.

The detailed warning repeats only if the problem changes, or comes back
after a working switch. The flag lives in __init__, not refresh_config(), which
runs every cycle. Other inverter types are unchanged. The test HA mock gains
input_boolean/turn_on and turn_off so the input_boolean case can be tested.

Freeze Export on these inverters is already not planned since #5542.
has_ge_eco_toggle is left set, as execute.py uses it to time GE exports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@springfall2008 springfall2008 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated comment from the triage bot.

Reviewed head ef51273b ("fix(inverter): warn once about an eco toggle that cannot be written, and never write a non-switch through it (#4909)") against main: no issues found.

What I checked: the new top-of-function gate in adjust_inverter_mode() (missing / fixed-value / wrong-domain branches, the warn-once state and its reset, and the record_status(had_errors=True) surface for wrong bindings); the callers in adjust_force_export() and execute.py, confirming the early return only skips the 30s GivTCP settle sleep (which is only reached as changed_start_end from the force-export leg, with no writes after it) and a write that could never succeed, while healthy switch/input_boolean paths keep the previous sequence; get_arg(indirect=False, index=...) semantics for the GE Cloud empty-slot and short-list cases; that has_ge_eco_toggle is set only for the GEC type and that non-toggle types are untouched; that refresh_config() (which re-derives inv_has_ge_eco_toggle every cycle) never resets the warn-once state, which is set in __init__ only; and the debug dump, which serialises the new eco_toggle_warned attribute as a plain string/None, so replay stays safe.

On the tests: the new test_adjust_ge_eco_toggle_warns_once asserts exactly 1 warning across cycles for a missing toggle and for a select, never a write for any refused binding, the status errors only for wrong bindings, the skipped sleep, and the re-warning after a working toggle; its snapshot/finally restore covers the inverter dict, shared args, both log/status monkey-patches and the dummy HA states. I traced the failure scenarios statically (a missing toggle logged per cycle on main, a select retried as select/turn_on, and the sleep running unconditionally on main), which supports the "fails on main" claim. The updated expectations for the two explicit-None cases match the documented behaviour change.

@springfall2008 springfall2008 removed the BOT_REVIEW Trigger an autotriage label Oct 19, 2026

This branch has not been deployed

No deployments
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.

3phase GE Cloud: no enable_eco_mode switch (or anything eco/demand-mode related) is created. So inverter_mode slot is empty

2 participants