Skip to content

Commit 956c132

Browse files
docs(fetch): correct the car_energy_reported_load check's docstrings (#5318 review)
minute_data() interpolates across a gap inside the history rather than leaving it flat, so only a stretch before the history or padded over a reset reads as no load; say so, and that a long outage over a charge can still count. The load history is only emptied when car_charging_hold is On as well. Give the test's nested load() helper a docstring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 03265bc commit 956c132

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎apps/predbat/fetch.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3455,7 +3455,9 @@ def car_energy_exceeds_load_windows(self):
34553455
34563456
The window in progress is left out: a cloud-polled load sensor can be many minutes behind the charger's, so it
34573457
reads short there. A window with no load at all is skipped - a house always draws something, so a flat stretch
3458-
is the load sensor missing data (the history is padded, so missing minutes read as no increment), not evidence.
3458+
is missing data (before the history starts, or where minute_data() padded over a reset), not evidence. A gap
3459+
inside the history is not flat: minute_data() interpolates across it, so a load-sensor outage of some hours over
3460+
a charge spreads that charge thinly across the gap and can still count.
34593461
"""
34603462
window = CAR_ENERGY_LOAD_CHECK_WINDOW
34613463
lag = CAR_ENERGY_LOAD_CHECK_LAG
@@ -3482,7 +3484,8 @@ def check_car_energy_reported_load(self):
34823484
from #5317). Warned once, and not again until no window shows it: the windows move with now, so a borderline count
34833485
can dip below the threshold and back from one cycle to the next.
34843486
3485-
With the switch On, Predbat subtracts car_charging_energy from the load history and, for an Octopus Intelligent car
3487+
With the switch On, Predbat subtracts car_charging_energy from the load history (when car_charging_hold is also On,
3488+
the default) and, for an Octopus Intelligent car
34863489
without a car_charging_now sensor, reads low house load as the car not charging. Against a load sensor that excludes
34873490
the charger, the first empties the load history and the second cancels dispatches that are really charging.
34883491
"""

‎apps/predbat/tests/test_car_energy_reported_load.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ def _setup(my_predbat, load_includes_car, lag=0, sessions=((60, 180),), car_kw=C
4747
my_predbat.car_charging_energy = _incrementing(lambda minute: car_kw / 60 if _charging(minute, sessions) else 0.0, history)
4848

4949
def load(minute):
50+
"""
51+
The house load the load sensor saw in the minute that many minutes ago, with the car in it when it includes the charger.
52+
"""
5053
if load_gap and load_gap[0] <= minute < load_gap[1]:
5154
return 0.0
5255
car = car_kw if (load_includes_car and _charging(minute + lag, sessions)) else 0.0

0 commit comments

Comments
 (0)