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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
@@ -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).
|
||||
|
||||
@@ -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 ----------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user