EV-20 round 3: no non-zero write while the meter is silent (C17); the age pause on a held read (C18)
checks / unit (pull_request) Successful in 35m34s
infra-pin / fresh (pull_request) Failing after 2s

While the meter's age is past meter_max_age_s, or on a held charger read,
Solar sends no non-zero current: no retry, no raise, no phase change begun,
and a phase change under way ends at its 0 A. 0 A is always allowed. On a
held read Solar still steps (Manual does not), so a pause due then is not
slipped. Rows in test_ev20_rig.py section 8.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
Claude
2026-11-24 01:24:36 +01:00
parent f62501174d
commit 3083093e22
4 changed files with 109 additions and 9 deletions
+25 -4
View File
@@ -498,12 +498,15 @@ class SunInputs:
def __init__(self, target_w=None, hold=False, auto=True, start_s=120.0,
pause_s=300.0, spare_w=None, room_w=0.0, margin_w=100.0,
first=DEFAULT_FIRST, unknown_s=0.0):
first=DEFAULT_FIRST, unknown_s=0.0, silent=False):
self.target_w, self.hold, self.auto = target_w, hold, auto
# EV-20 rig round 2: how long the sun has already been unknown when
# the cause is the meter's own age (`ha_signed`): the pause is timed
# from that age, not from the cycle that noticed it.
self.unknown_s = unknown_s
# EV-20 SPIKE-06 C17 (N8): the meter is known silent (its age past
# `meter_max_age_s`): no non-zero current goes out, only 0 A.
self.silent = silent
self.start_s, self.pause_s = start_s, pause_s
self.spare_w, self.room_w, self.margin_w = spare_w, room_w, margin_w
self.first = first
@@ -730,6 +733,7 @@ class SolarWriter(ManualWriter):
self.stuck_starts = 0 # SPIKE-06 C12: starts under one stuck verdict
self.stuck_wait = None # ... used up: the next start not before
self.stuck_warned = False # ... and its one CHARGER_REFUSED was given
self.nz_block = False # C17/C18: this step writes 0 A at most
def owe_start(self) -> None:
"""C1: the add-on starts in Off while an exit 0 A of its own was still
@@ -837,6 +841,8 @@ class SolarWriter(ManualWriter):
`MAX_TRIES` and never waits (0 A is the safe side)."""
if self.hold:
return
if want > TOL_A and self.nz_block:
return # C17/C18: 0 A only, no retry or raise
if self.sent_a is not None and abs(self.sent_a - want) <= TOL_A:
if self.taken or self.gave_up or (
self.fail_at is not None
@@ -985,11 +991,17 @@ class SolarWriter(ManualWriter):
# ------------------------------------------------------------- step
async def step(self, drv, r, *, mode, sun, clamp, now, tracker, writing,
status, clock=None):
status, clock=None, held=False):
"""One cycle. `sun` is `SunInputs` (None outside Solar); `writing` is
False in shadow mode, while control is stopped, under a safety stop
and while stopping."""
and while stopping. `held`: the charger missed this read and the last
reading stands in (EV-20 round 2): the step may pause, never raise."""
self._clock = clock or (lambda: now)
# SPIKE-06 C17/C18: while the meter is silent, or on a held read, no
# non-zero current goes out (no retry, no raise, no closing current
# of a phase change); 0 A always may.
self.nz_block = bool(held or (sun is not None
and getattr(sun, "silent", False)))
entering = mode == SOLAR and self.mode_was != SOLAR
self.mode_was = mode
if entering:
@@ -1130,6 +1142,15 @@ class SolarWriter(ManualWriter):
gap = self._gap_ok(now)
if self.sent_a == 0.0 and not self.taken:
self.plan.ok_since = None # 0 A first, then the start rule
if self.seq is not None and self.nz_block:
# C17: a phase change under way ends at its 0 A; no select and no
# closing current while the meter is silent. The plan pauses and
# starts again by the start rule.
self.seq = None
self.plan.end_switch(False)
self.plan.pause("unknown")
await self._put(drv, 0.0, cur, now, tracker)
return
if self.seq is not None:
self._plan_step(sun, now, clamp, self.plan.n, gap)
if self.plan.a < CH.MIN_A:
@@ -1172,7 +1193,7 @@ class SolarWriter(ManualWriter):
return
self._plan_step(sun, now, clamp, n_now, gap)
want = self.amps_out(clamp)
if want >= CH.MIN_A and self.plan.switch \
if want >= CH.MIN_A and self.plan.switch and not self.nz_block \
and self.plan.n != n_now and not self.single:
if self.gave_up or (self.fail_at is not None
and now - self.fail_at < RETRY_S):