From f62501174dbe3356d964c54de2f65b04bb5114e2 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 00:46:34 +0100 Subject: [PATCH] EV-20 rig round 2: hold only real read gaps, not a reading's own unavailable cause A failed read or every required entity unavailable is a gap and keeps the last reading; one entity missing, a wrong power unit or login off stay the reading they are (EV-03 round 4 rows green again). Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w --- .../DECISIONS/EV-20-solar-mode.md | 5 ++++- goodwe_controller/app/chargers.py | 21 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/goodwe_controller/DECISIONS/EV-20-solar-mode.md b/goodwe_controller/DECISIONS/EV-20-solar-mode.md index dcf2f45..061d8e1 100644 --- a/goodwe_controller/DECISIONS/EV-20-solar-mode.md +++ b/goodwe_controller/DECISIONS/EV-20-solar-mode.md @@ -148,7 +148,10 @@ one small set of facts and derives every path from them: - **A short charger read gap** (chargers.py `CarTracker.observe`, shared by Solar, Manual and the peak guard): a reading missing for less than - `stale_input_s` keeps the last trusted reading (`held`); nothing is decided + `stale_input_s` keeps the last trusted reading (`held`). A gap is a read + that got no answer, or every required entity unavailable; one entity + missing, a wrong power unit or the login off stay readings of their own + (EV-03 round 4, unchanged); nothing is decided or written in that cycle (`ctl_car.car_step` returns), and it neither arms nor clears the stuck check. At `stale_input_s` the missing reading is taken as before (the safe path: the charger is gone, 0 A first on its return). diff --git a/goodwe_controller/app/chargers.py b/goodwe_controller/app/chargers.py index cb311d7..71afd92 100644 --- a/goodwe_controller/app/chargers.py +++ b/goodwe_controller/app/chargers.py @@ -255,6 +255,18 @@ def display_class(text) -> str | None: return None +def _is_gap(why) -> bool: + """EV-20: does this unavailable reading's cause mean "no answer" (a read + gap), not a reading the charger gave?""" + why = why or "" + if why == "no answer": + return True + if why.startswith("no answer from "): + gone = {x.strip() for x in why[len("no answer from "):].split(",")} + return set(REQUIRED) <= gone + return False + + def reading_from_states(states: dict) -> ChargerReading: """A `ChargerReading` from `{role: state object or None}`. Pure.""" def txt(role): @@ -770,10 +782,13 @@ class CarTracker: self._status_edge(now, now_utc) def _held(self, r, now: float) -> bool: - """Is this missing reading a short gap behind a usable one?""" + """Is this missing reading a short gap behind a usable one? A gap is + a read that failed (no answer at all) or Home Assistant showing every + required entity unavailable. One entity missing, a wrong unit or the + login off are readings of their own (EV-03), never held.""" last = self.reading - return (not r.available and last is not None and last.available - and self.last_ok is not None + return (not r.available and _is_gap(r.why) and last is not None + and last.available and self.last_ok is not None and now - self.last_ok < self.stale_s) # -- reachability ----------------------------------------------------------