EV-05 round 2: the peak cut waits 15 s while a battery can give
Owner 2026-11-18 (dev finding 1, brief v4 Expected 8): while a battery is above its cut-out, the car's peak cut waits until the guard has wanted power for 15 s in a row (CUT_WAIT_S), so a cloud edge the batteries catch does not pause the car. It cuts at once with no battery able, or with 120 s or less of the 15-minute period left (CUT_NEAR_END_S: waiting 15 s then costs at most 8/7 of the cut, taken off the car at once). Tests: T21/T22 cut at 15 s and not sooner, the period lands under the aim; T21b a house step and a cloud edge the batteries catch: no cut, no pause; T24 (c) late in the period: the cut at once, under the aim; T12's cut row with the batteries at their cut-out. The harness's battery level model was 1000x too fast (round 1); fixed. The 10-hour day: 0 cut pauses in both priorities. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,16 @@ 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
|
||||
CAR_SUN_KEY = "car_sun" # EV-05: {day, kwh} charged from the sun today
|
||||
# EV-05 round 2 (owner 2026-11-18): while a battery can still give power the
|
||||
# peak cut waits until the guard has wanted power this long in a row, so a
|
||||
# cloud edge the batteries catch does not pause the car. It cuts at once when
|
||||
# no battery can give (all at their cut-out) or with this little of the
|
||||
# 15-minute period left: waiting 15 s with R s left raises what must come off
|
||||
# afterwards by R / (R - 15), at most 8/7 at R = 120 s, and the cut takes it
|
||||
# off the car at once then (test_ev05.py T21, T21b, T24c: the period lands
|
||||
# under the aim).
|
||||
CUT_WAIT_S = 15.0
|
||||
CUT_NEAR_END_S = 120.0
|
||||
# EV-05: at shutdown the charger's 0 A waits at most this long, then the
|
||||
# inverters are released whatever the charger did.
|
||||
RELEASE_WAIT_S = 15.0
|
||||
@@ -67,6 +77,7 @@ class CarMixin:
|
||||
self.car_cut_w = 0.0
|
||||
self._car_key = None
|
||||
self._car_late_s = None
|
||||
self._car_want_since = None # EV-05: the guard wants power since
|
||||
self._car_sun_last = None
|
||||
self._car_error_notified = False
|
||||
sun = data.get(CAR_SUN_KEY)
|
||||
@@ -433,6 +444,18 @@ class CarMixin:
|
||||
<= OWN_PAUSE_MAX_S
|
||||
return 0.0 <= mono - wr.phase_done_at <= OWN_PAUSE_TAIL_S
|
||||
|
||||
def _car_batt_able(self) -> bool:
|
||||
"""EV-05: can a battery still give power? One that is above its own
|
||||
cut-out level, not refusing to give and not under a safety stop."""
|
||||
for inv in self.inverters:
|
||||
soc, floor = inv.soc, inv.bms_soc_floor
|
||||
if soc is None or floor is None or inv.sign_wd.tripped \
|
||||
or (inv.refused or 0) > 0:
|
||||
continue
|
||||
if float(soc) > float(floor):
|
||||
return True
|
||||
return False
|
||||
|
||||
def _car_solar_pause(self, mono) -> bool:
|
||||
"""EV-05: Solar's own 0 A (a pause, the peak cut, the phase change)
|
||||
gets EV-15's grace, bounded the same way: from the moment it is sent,
|
||||
@@ -548,6 +571,7 @@ class CarMixin:
|
||||
# What the guard would ASK the batteries to give (`wanted_w`, its floor
|
||||
# before the rating) is taken off the car instead, up to the excess:
|
||||
# batteries that only stop charging are not asked for anything.
|
||||
cut = 0.0
|
||||
if self.car_solar_mode() and real_proj is not None \
|
||||
and target_w is not None and real_proj.block_start is not None \
|
||||
and guard is not None and guard.engaged and guard.blind is None:
|
||||
@@ -555,7 +579,16 @@ class CarMixin:
|
||||
want = guard.wanted_w
|
||||
if ex is not None and want is not None and math.isfinite(ex) \
|
||||
and math.isfinite(want) and ex > 0.0 and want > 0.0:
|
||||
self.car_cut_w = float(min(ex, want))
|
||||
cut = float(min(ex, want))
|
||||
if cut > 0.0:
|
||||
if self._car_want_since is None:
|
||||
self._car_want_since = mono
|
||||
left = QUARTER_S - float(real_proj.elapsed_s)
|
||||
if not self._car_batt_able() or left <= CUT_NEAR_END_S \
|
||||
or mono - self._car_want_since >= CUT_WAIT_S:
|
||||
self.car_cut_w = cut
|
||||
else:
|
||||
self._car_want_since = None
|
||||
self._car_sun_tick(mono)
|
||||
w = self.car_alarm_w()
|
||||
# EV-15: the figure for grading only. Our own phase change holds the
|
||||
|
||||
Reference in New Issue
Block a user