Skip to content

fix(gecloud): stop deleting a manual inverter_mode override during automatic config (#5056) - #5059

Merged
springfall2008 merged 1 commit into
springfall2008:mainfrom
kennedy-nic:fix/gecloud-inverter-mode-override
Sep 11, 2026
Merged

springfall2008 merged 1 commit into
springfall2008:mainfrom
kennedy-nic:fix/gecloud-inverter-mode-override

Conversation

@kennedy-nic

Copy link
Copy Markdown
Contributor

Fixes #5056

Summary

On GE Cloud devices where the automatic register scan finds no matching entity for inverter_mode (no enable_eco_mode register on this hardware class), async_automatic_config() called self.set_arg("inverter_mode", None). set_arg() treats None as "delete this key," so any value the user had explicitly set for inverter_mode in apps.yaml was deleted on every config refresh while ge_cloud_automatic: true — with no way to work around it from apps.yaml, since the key was gone again before adjust_inverter_mode() ever got a chance to read it.

This is exactly the class of problem export_limit already solves a few lines later in the same function: set_arg_auto(..., overwrite=False) (added for #4494 / PR #4500, and used again for site export limits in #4978) fills a key in when the user has set nothing, but leaves an explicit apps.yaml value alone rather than deleting it. inverter_mode had just never been switched over to it.

Fix

- self.set_arg("inverter_mode", build_entities("switch", ["enable_eco_mode"]))
+ self.set_arg_auto("inverter_mode", build_entities("switch", ["enable_eco_mode"]), overwrite=False)

Scoped to inverter_mode only — the other set_arg(key, build_entities(...)) call sites in this function (charge_rate, discharge_rate, reserve, charge_limit, scheduled_charge_enable, etc.) have the same delete-on-None behaviour but aren't part of this issue, per the reporter's own framing.

Testing

A GitHub bot triage review of the issue flagged that the existing coverage at test_ge_cloud.py:4164 (asserting inverter_mode is None when the eco toggle is absent) only passed because that assertion can't distinguish "key never set" from "key deleted" — it never actually populated args_from_apps_yaml with a manual value, so it never exercised set_arg_auto's overwrite=False branch for this key at all. Added a new case to _test_async_automatic_config that seeds both config_args["inverter_mode"] and (critically) base.args_from_apps_yaml["inverter_mode"] with a manually-configured entity, then runs auto-config against a device with no eco-mode register, and asserts the manual value survives.

  • tools/triage_test.sh ge_cloud: all passing, including the new case — verified red on the unfixed code and green on the fix. The new case is an added assertion inside the existing automatic_config test function rather than a separately-registered test, so the total stays at 94 either way (Predbat's suite counts registered test functions, not individual assertions); what changes is whether that function passes. Confirmed the wiring directly: reverting just the one-line gecloud.py change while keeping the new test flips automatic_config to failing (EXCEPTION in automatic_config: manually configured inverter_mode should survive auto-config when no eco toggle switch is discovered, 93 passed / 1 failed of 94); restoring the fix returns it to 94 passed, 0 failed.
  • run_pre_commit (pre-commit run --all-files + ./run_all --quick): passing aside from four pre-existing failures unrelated to gecloud — two Windows-specific environment issues (a pathlib crash in tools/triage_daemon.py, and a ctypes/glibc LoadLibrary(None) bug hit by two unrelated tests) and a missing compiled prediction kernel causing two golden-baseline tests to drift onto the slower Python fallback engine — all four reproducing identically on unmodified main. With those excluded, the remaining 306 quick tests pass.

Related

🤖 Generated with Claude Code

…tomatic config

async_automatic_config() called set_arg("inverter_mode", None) whenever no
enable_eco_mode register was found, which deletes any value the user had set
in apps.yaml on every config refresh. Switch to set_arg_auto(..., overwrite=False),
the same pattern already used for export_limit (springfall2008#4494/springfall2008#4500, springfall2008#4978), so a manual
override survives instead of being silently wiped.

Adds a test case that actually exercises the overwrite=False path by seeding
args_from_apps_yaml, closing the coverage gap a bot triage review flagged in the
existing test.

Fixes springfall2008#5056

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No unresolved blocking issues were identified.

Pull request overview

This PR preserves manually configured inverter_mode values during GE Cloud automatic configuration.

Changes:

  • Uses set_arg_auto(..., overwrite=False).
  • Adds regression coverage for manual override preservation.
File summaries
File Description
apps/predbat/tests/test_ge_cloud.py Tests that manual overrides survive automatic configuration.
apps/predbat/gecloud.py Preserves explicit inverter_mode values.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

GE Cloud: automatic config silently deletes a manual inverter_mode override instead of falling back to it

3 participants