Repository navigation
fix(inverter): treat a failing ge_cloud_direct as transient, and name the source - #4642
Merged
Merged
Conversation
The transient branch at inverter.py:1495 gates on self.rest_api, and its
comment names GivEnergy cloud "no devices" as the case it exists to catch
-- but that case can never reach it. ge_cloud_direct sets neither rest_api
nor charge_start_time, because it auto-configures the charge window at
runtime from whatever device the cloud reports. So a cloud-backed instance
whose fetch fails falls straight past into the permanent-setup-gap branch
and raises ValueError, killing the plan for something that is not a setup
gap at all and is often not even the user's to fix.
Observed live on three instances, three different upstream causes, one
identical error:
HTTP 402 from GE Cloud on every endpoint (lapsed entitlement)
"No devices found, check your GE Cloud credentials" (stale credential)
HTTP 401 on both GE Cloud and Octopus (user had revoked their keys)
All three read:
Error: Inverter 0 unable to read charge window time as neither REST,
charge_start_time or charge_start_hour are set
Every one of those instances had apps.yaml identical to healthy ones --
ge_cloud_direct set, no givtcp_rest, no charge_start_time. The message
asserts a configuration fault that does not exist, and diagnosing it meant
ruling out config, then pod networking, then node placement, before
arriving at a 401.
Two changes:
1. ge_cloud_direct joins rest_api in the transient branch, so a cloud
failure gets the existing safe-defaults/retry-next-update handling
instead of raising.
2. Both messages now name the source. The retry warning matters most: it
is what a user actually sees once (1) stops these raising, and
"charge_start_time is None" would send them to the one file that is
fine. It now says which source returned nothing and suggests checking
credentials and that the account still has the inverter attached --
Predbat cannot tell 402 from 401 from no-devices here, but it can say
where the data should have come from.
The no-source-configured error also now lists what to set, rather than
naming three internals the reader must map back to config keys.
Tests: existing charge_window_no_source_configured updated for the new
wording (its own docstring asks for "a clear, informative ValueError", so
the assertion followed the message). New
charge_window_ge_cloud_configured_but_no_data_yet mirrors the existing
REST transient test and pins that the status names GE Cloud -- without
that, (1) would silently regress back to blaming apps.yaml.
unit_test.py --test inverter --test inverter_multi
--test multi_inverter_status --test find_charge_window
-> All tests passed
black --check and ruff F401 clean, no trailing whitespace. Committed with
--no-verify because the pre-commit install in this environment is broken
(ModuleNotFoundError: yaml, unrelated to this change); cspell likewise
could not run locally as its en-gb dictionary does not resolve here. Both
are left to pre-commit.ci.
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.
The branch that can't catch its own use case
inverter.py:1495gates the transient path onself.rest_api, and its comment names the case it exists for:But that case can never reach it.
ge_cloud_directsets neitherrest_apinorcharge_start_time— it auto-configures the charge window at runtime from whatever device the cloud reports. So a cloud-backed instance whose fetch fails falls straight past into the permanent-setup-gap branch and raisesValueError, killing the plan.Observed live: three causes, one message
Three instances on a cloud deployment, three different upstream failures:
All three reported:
Every one had
apps.yamlidentical to healthy instances —ge_cloud_directset, nogivtcp_rest, nocharge_start_time. The message asserts a configuration fault that doesn't exist. Diagnosing it meant ruling out config, then pod networking, then node placement, before arriving at a 401.Changes
1.
ge_cloud_directjoinsrest_apiin the transient branch — a cloud failure now gets the existing safe-defaults/retry-next-update handling instead of raising.2. Both messages name the source. The retry warning matters most: it's what a user actually sees once (1) stops these raising, and
charge_start_time is Nonewould send them to the one file that's fine. It now says which source returned nothing and suggests checking credentials and that the account still has the inverter attached. Predbat can't tell 402 from 401 from no-devices here, but it can say where the data should have come from.The no-source-configured error also now lists what to set, rather than naming three internals the reader has to map back to config keys.
Tests
charge_window_no_source_configured— assertion updated for the new wording. Its docstring asks for "a clear, informative ValueError", so the assertion followed the message rather than pinning the old text.charge_window_ge_cloud_configured_but_no_data_yet— mirrors the existing REST transient test, and pins that the status names GE Cloud. Without that, change (1) could silently regress to blamingapps.yamlagain.black --checkandruff --select F401clean, no trailing whitespace.Note:
pre-commitcouldn't run in my environment (ModuleNotFoundError: yamlin the local install), andcspellcouldn't resolve itsen-gbdictionary there either — so the commit used--no-verifyand both are left to pre-commit.ci. Everything else in the hook list I ran by hand.Context
Relates to the maintainer discussion on #4288 / #4179 that produced this branch. The permanent-gap behaviour is unchanged and still correct — this only stops a configured cloud source being misclassified as no source.