MAINT-28 fix-forward: the peak pause ends only on a settled house estimate, and a pack under its peak reserve gives nothing for the house while it holds
Rig FAIL (TEST-23, f3f9483). F-1: the hold ended at each guard step because
grid + site_batt_w added a new meter reading to a battery reading up to 10 s
old. It now ends only when no battery reading may pre-date a step up of its
command (Controller._batts_settled()). F-2: while the pause holds, a pack in
maintenance CHARGE at or under its peak reserve is limited to 0 W, so it gives
only what the guard claims for the peak. Sim: Lag.batt_period_s (a held 10 s
register). Tests: test_maint28b.py. DECISIONS updated.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
f3f9483d9c
commit
34b81e8aeb
@@ -19,6 +19,7 @@ from . import packmode
|
||||
from . import priceruns
|
||||
from . import solarfc
|
||||
from . import control as _ctl
|
||||
from . import freshness
|
||||
from . import messages
|
||||
from .maintenance import CHARGE, DRAIN, HOLD, IDLE, MaintConfig, POWER_MOVING
|
||||
from .mqtt import MODE_LABELS, USE_OFF, USE_ON, unit_slugs, unit_state_key
|
||||
@@ -49,6 +50,11 @@ EDGE_HOLD_S = _ctl.PLANT_SETTLE_S
|
||||
HOUSE_PROFILE_KEY = "house_profile"
|
||||
|
||||
|
||||
# MAINT-28: a step of a battery's command, in W, after which its reading is not
|
||||
# current until a changed one arrives (`Controller._batts_settled()`).
|
||||
MAINT_STEP_W = 100.0
|
||||
|
||||
|
||||
# OPT-34: the level of a night grid charge that has started, so it does not
|
||||
# drop when the forecast goes (`Controller._latch_charge()`).
|
||||
CHARGE_LATCH_KEY = "night_charge_latch"
|
||||
@@ -711,6 +717,36 @@ class TradeMixin:
|
||||
lo = hi = float(inv.batt)
|
||||
self._read_span[inv.name] = (min(lo, cmd), max(hi, cmd), since)
|
||||
|
||||
def _batts_settled(self) -> bool:
|
||||
"""MAINT-28: False while a battery reading may pre-date a step UP of
|
||||
its command, so `grid + site_batt_w` is a new grid and an old battery.
|
||||
DECISIONS/MAINT-28-hold-the-pause-in-a-peak.md"""
|
||||
now, ok = self._now_mono, True
|
||||
if now is None:
|
||||
return True
|
||||
for inv in self.inverters:
|
||||
cmd = float(inv.standing_w())
|
||||
seen = self._m28_step.get(inv.name)
|
||||
if seen is None:
|
||||
seen = self._m28_step[inv.name] = (cmd, None)
|
||||
elif abs(cmd - seen[0]) >= MAINT_STEP_W:
|
||||
seen = self._m28_step[inv.name] = (
|
||||
cmd, now if cmd > seen[0] else seen[1])
|
||||
at = seen[1]
|
||||
if at is None or now - at >= freshness.BATT_OBLIGED_S:
|
||||
continue
|
||||
got = inv.batt_fresh.changed_mono
|
||||
if got is None or got < at + freshness.PLANT_SETTLE_S:
|
||||
ok = False
|
||||
return ok
|
||||
|
||||
def _under_reserve(self) -> frozenset:
|
||||
"""MAINT-28: the batteries at or under their peak reserve now
|
||||
(`peakguard.reserve_split()`). DECISIONS/MAINT-28-hold-the-pause-in-a-peak.md"""
|
||||
floor = float(self.o.get(
|
||||
"peak_soc_floor", peakguard.PEAK_OPTION_DEFAULTS["peak_soc_floor"]))
|
||||
return frozenset(peakguard.reserve_split(self.packs, floor)[1])
|
||||
|
||||
def _reseed_drop(self, live) -> None:
|
||||
"""SAFETY-96, N>=2: a battery that drops out of the split (stale link)
|
||||
leaves the loop's start point, so the others take over at one slew step
|
||||
|
||||
Reference in New Issue
Block a user