Repository navigation
fix(inverter): warn once about an eco toggle that cannot be written, and never write a non-switch through it (#4909) - #5647
chalfontchubby wants to merge 3 commits into
Conversation
…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
left a comment
There was a problem hiding this comment.
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.
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_modeswitch for them, but theGECinverter type still setshas_ge_eco_toggle, soadjust_inverter_mode()kept trying to drive a switch that does not exist:No entity_id for ECO Togglelogged on every plan cycle.select.*_modemapped by hand): the switch path called the non-existentselect.turn_onten times per attempt. In the force-export direction it reported "No write needed" without writing, because the select's state read back as a False switch.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:switch.*/input_boolean.*off)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__, notrefresh_config(), which runs every cycle. Other inverter types are unchanged.Behaviour changes worth knowing:
inverter_modeslot used to be silent. It now gets the one-off warning, since that is the mixed-fleet 3-phase case.Deliberately not done
has_ge_eco_togglefor these inverters.execute.py:904also 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.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 aGEone. The reporter has since moved to GE Cloud automatic config. Happy to add it if wanted.Tests
test_adjust_ge_eco_toggle_warns_onceintest_inverter.pyrunsrefresh_config()between cycles, as execute does. It covers:EcoandFalse;input_booleanand a workingswitch;Nonenow expect the one-off warning.TestHAInterfacemock gainsinput_boolean/turn_onandturn_off../run_all --quickpasses.run_pre_commitpasses (all 14 hooks).Review
/code-review high. The last two found no correctness issues.check_write_entityor discovery-time flags (a refactor).sensor(Predbat never creates a sensor stand-in for the eco toggle, andcoordinator.pyonly setshas_ge_eco_togglefor aswitch).Out of range indexwarning for a short per-inverterinverter_modelist.🤖 Generated with Claude Code