EV-19 review round 1: discount a battery rise only while the meter has not moved
checks / unit (pull_request) Successful in 31m32s
infra-pin / fresh (pull_request) Failing after 1s

[Major] The rise discount applied to any rise, also one the meter
already shows, so an honest house step answered by one cycle of battery
power alarmed one cycle after base (review repro: T6 step + burst, R+6
instead of R+5). Now a reading above both earlier ones is discounted only
while the meter's house side (held - car; held alone when a car figure is
unknown) moved no more than RISE_STILL_W (50 W) since the last cycle.

Tests: the burst shapes (unit, meter in step and one cycle late;
controller, step at R+5 and R+30, 3 000 / 4 600 W) at base's second; the
"N6 unit" check tightened to the rise cycle; the RISE_STILL_W boundary;
a pin on EV-18's `_car_over_now` (mC); T10 restarts at R-1 and R (mE).
test_ev19: 144 of 144 here, 52 red on 43b0db7.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
ems-agent
2026-11-20 22:13:19 +01:00
co-authored by Claude
parent 4950a2374f
commit c2bb32ec93
4 changed files with 127 additions and 20 deletions
+21 -6
View File
@@ -31,6 +31,9 @@ OVER_OFF_HOLD_S = 180.0
OWN_PAUSE_MAX_S = (carmode.ZERO_WAIT_S + carmode.SETTLE_S
+ carmode.MAX_TRIES * 15.0 + 10.0)
OWN_PAUSE_TAIL_S = chargers.CORR_WINDOW_S
# EV-19: the meter's house side (held - car) moved no more than this since the
# last cycle: it has not shown a battery rise the reading already shows.
RISE_STILL_W = 50.0
class CarMixin:
@@ -59,6 +62,7 @@ class CarMixin:
self._car_over_since = None
self._car_over_gone = None
self._car_batt_prev = self._car_batt_prev2 = None
self._car_hx_prev = None # EV-19: last cycle's (held, car W)
self._car_need_real = self._car_need_excl = False # EV-10 latches
self._car_need_house = self._car_over_now = False # EV-18 latches
self._car_latch_block = None
@@ -416,12 +420,6 @@ class CarMixin:
now, prev = self.site_batt_w, self._car_batt_prev
prev2, self._car_batt_prev2 = self._car_batt_prev2, prev
self._car_batt_prev = now
# EV-19: the reading can show a rise one cycle before the meter does
# (the batteries pick up the house at the reserve), so a reading above
# both earlier ones is not yet counted as house.
seen = now
if now is not None and prev is not None and prev2 is not None:
seen = min(float(now), max(float(prev), float(prev2)))
wants = bool(guard is not None and guard.engaged
and guard.blind is None
and (guard.wanted_w or 0.0) > 0.0)
@@ -433,6 +431,23 @@ class CarMixin:
if batt is not None and prev is not None:
batt = min(float(batt), float(prev))
excl = self.car_exclude_alarm(real_proj, w)
# EV-19: the reading can show a rise one cycle before the meter does
# (the batteries pick up the house at the reserve). While the meter's
# house side (held - car; held alone when a car figure is unknown) has
# not moved, a reading above both earlier ones is not yet counted as
# house; a meter that moved shows it (no discount).
held = float(real_proj.held_w)
hp, self._car_hx_prev = self._car_hx_prev, (held, w)
still = False
if hp is not None:
moved = held - hp[0]
if w is not None and hp[1] is not None:
moved -= float(w) - float(hp[1])
still = abs(moved) <= RISE_STILL_W
seen = now
if still and now is not None and prev is not None \
and prev2 is not None:
seen = min(float(now), max(float(prev), float(prev2)))
if wants and batt is not None:
self._car_need_real = self._car_need_real or \
peakguard.misses_aim(real_proj, batt_w=batt,