EV-20 rig round 2: hold only real read gaps, not a reading's own unavailable cause
checks / unit (pull_request) Successful in 40m43s
infra-pin / fresh (pull_request) Failing after 1s

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
Claude
2026-11-24 00:46:34 +01:00
parent 49e010fdfb
commit f62501174d
2 changed files with 22 additions and 4 deletions
@@ -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).
+18 -3
View File
@@ -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 ----------------------------------------------------------