MAINT-28: during a real peak the maintenance charge stays paused until the house is clear of the aim
infra-pin / fresh (pull_request) Successful in 2s
checks / unit (pull_request) Failing after 1h10m11s

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
glenn schrooyen
2026-11-12 21:51:56 +01:00
co-authored by Claude
parent 1b5f7c9ccb
commit 8cd10ee6aa
5 changed files with 278 additions and 2 deletions
+7 -2
View File
@@ -564,8 +564,13 @@ class CycleMixin:
maint_aim = peakguard.quarter_target_w(
float(self.o.get("peak_cap_w", 3500)),
self.peak_margin_w, _reading)
if peakguard.shaping_suspended(
self.peak_guard, self.peak_fc, maint_aim):
# MAINT-28: stays paused until the house is clear of the aim.
house = (None if self.grid is None or self.site_batt_w is None
else float(self.grid) + float(self.site_batt_w))
self._maint_peak_hold = peakguard.shaping_held(
self._maint_peak_hold, self.peak_guard, self.peak_fc,
maint_aim, house)
if self._maint_peak_hold:
# Edge-logged: level-logging here would write one line per
# cycle for as long as the event lasts and flush the 40-line
# action log of the very context that explains it.
+1
View File
@@ -505,6 +505,7 @@ class Controller(InputsMixin, WritesMixin, TradeMixin, CycleMixin, AlarmsMixin,
self._land_batt_prev = None
self._peak_needed = False
self._maint_shape_suspended = False
self._maint_peak_hold = False # MAINT-28
# OPT-11: battery modes, off by default (SAFETY-10 section 1). Each
# battery's mode and on/off switch live in the store, not in options,
# so a change applies at once (`pack_use`, `pack_mode`).
+18
View File
@@ -28,6 +28,10 @@ FLOOR_AT_SOC_FLOOR = "the battery level is at or below the peak reserve"
SOURCE = "peak"
# MAINT-28. Watts the house must sit under the aim before a paused maintenance
# charge resumes. DECISIONS/MAINT-28-hold-the-pause-in-a-peak.md.
MAINT_RESUME_UNDER_W = 300.0
# Mirror of config.yaml's peak options, pinned to the file by
# test_peakguard.py. Not a read: `decide()` takes them as arguments.
PEAK_OPTION_DEFAULTS = {
@@ -446,6 +450,20 @@ def shaping_suspended(decision, peak_forecast_w, cap_w) -> bool:
return decision is not None and decision.engaged
def shaping_held(held, decision, peak_forecast_w, aim_w, house_w) -> bool:
"""MAINT-28. `shaping_suspended()`, kept on until the house is
`MAINT_RESUME_UNDER_W` under `aim_w` (`peak_forecast_w` stands in for an
unread house; neither read: not held, as SAFETY-63). Only ever pauses the
maintenance charge, never a cut-back.
DECISIONS/MAINT-28-hold-the-pause-in-a-peak.md."""
if shaping_suspended(decision, peak_forecast_w, aim_w):
return True
if not held:
return False
level = house_w if house_w is not None else peak_forecast_w
return level is not None and level > float(aim_w) - MAINT_RESUME_UNDER_W
def cap_floor(decision, cap_w):
"""SAFETY-128: the floor no higher than `cap_w` (the command standing while
the readings have not answered it), or `decision` unchanged when None.