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:
@@ -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