Skip to content

fix(plan): show the held part of a charge window as HoldChrg, not Chrg (#5990) - #6006

Open
chalfontchubby wants to merge 8 commits into
mainfrom
fix/hold-charge-label-5990
Open

chalfontchubby wants to merge 8 commits into
mainfrom
fix/hold-charge-label-5990

Conversation

@chalfontchubby

@chalfontchubby chalfontchubby commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Posted by Claude on Rik's behalf.

Fixes #5990.

What users see

A charge window that charges up to its target and then holds there was drawn as one Chrg ↗ 100 cell for the whole window. In #5990 that was 05:30 to 16:00, with the battery sitting at 100% the whole time. The plan now shows Chrg for the part that charges and HoldChrg → for the part that holds.

This is display only. What Predbat plans and what it sends to the inverter are unchanged; execution already reports "Hold charging" once SoC reaches the target.

Why it happened

The plan table merges a window into one rowspan cell and labels it once, from the lowest predicted SoC across the span. Two things went wrong:

  1. The label covered the whole window. A window that charges 90→100% and then holds has a minimum below 100%, so all of it read Chrg.
  2. The SoC scan behind the label ran past the span drawn. It ran to window end - minute_now_align, which goes past an export that cuts the span. Mid-slot, it also goes up to 25 minutes past the window. This is what the reporter's own plan hit: SoC was 100% for every row from 05:30 to 16:00, but an export at 16:30 pulled the scanned minimum down. Export spans had the same overshoot, which could show Exp where HoldExp was right.

The change (Output.publish_html_plan)

  • A span ends at the last whole row it draws: the window's end, an export cutting it, or the end of the plan.
  • A charge span is split at the earliest row boundary from which SoC stays at the target to the span's end. This is the same test the HoldChrg label applies, now shared through charge_window_held() and charge_window_target_percent().
  • Both charge and export labels are judged on the rows the span draws, not the whole window.

Evidence

  • Replaying the reporter's predbat_debug.yaml against this branch, the 22-row Chrg span becomes a 22-row HoldChrg span. The recomputed plan splits into Chrg then HoldChrg spans.
  • Test 18 in test_plan_why_reason adds 11 cases. 8 fail on main: charge-then-hold, held until an export, mid-slot charge, mid-slot export, a dip after reaching target, start-dip-recover, a window ending mid-row, and a span cut by the end of the plan. The other 3 (held throughout, never reaching target, and a freeze window whose SoC rises above the reserve staying one FrzChrg span) guard existing behaviour; the freeze case fails if the freeze exclusion in charge_window_held() is removed.
  • The quick suite and pre-commit pass.

Not changed

  • An export that reaches its target and then sits idle is still one Exp span. There is no label for "exported to target, now idle", because HoldExp means the target can't be reached. That needs a decision on a label, so it is left for a follow-up.

Side effect

  • The Chrg span's rate tooltip now covers only the rows that charge when a window is split, because the split also moves charge_end_minute to the split point. The HoldChrg reason text has no rate in it, so the held part's rates are only in the rate column. You only see this when the rate changes inside the window, for example at an Agile slot boundary.

🤖 Generated with Claude Code

chalfontchubby and others added 5 commits November 6, 2026 15:48
…5990)

A charge window that charged up to its target and then held there was drawn
as one merged Chrg cell, because the label was taken from the lowest SoC over
the whole window. The span now ends where the predicted SoC reaches the target,
so the rest starts its own HoldChrg span. The SoC scan behind the label also
stops at the span drawn rather than the window's end, so an export that cuts
the window no longer turns a held span into Chrg.

Display only: what is planned and executed is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
)

The SoC scan behind an export span's label ran to the window's end measured
from the aligned slot, overshooting by however far into the slot "now" is. A
charge straight after an export that never reaches its target then lifted the
scanned maximum and showed Exp instead of HoldExp. Scan to the window's end
measured from now, as the charge span now does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d stop label scans at the plan's end (#5990)

Review follow-ups. A window that touched its target and then dipped below it
was split into two adjacent Chrg cells; the split now comes at the earliest
boundary from which SoC stays at the target to the end of the span, the same
test the HoldChrg label applies. The label scans for charge and export spans
also stop where the table stops drawing, so a span cut by the end of the plan
is not labelled from SoC past it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Second review pass. The split now also covers a window that starts at its
target, dips below it and recovers: it is held from the recovery, where
before it stayed Chrg throughout. Both the split and the span labels are
judged on the whole rows the span draws, so a window ending part way through
a row, or past the end of the plan, is not labelled from the part drawn on its
own. The split is skipped where an export shares the row, as no span is drawn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…een the split and the label (#5990)

The span split and the HoldChrg label each resolved a charge window's target
and applied the held-at-target test on their own. Both now go through
charge_window_target_percent() and charge_window_held(), and
get_charge_export_text() uses the same target lookup, so they cannot drift.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the BOT_REVIEW Trigger an autotriage label Nov 6, 2026

@springfall2008 springfall2008 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated comment from the triage bot.

Reviewed at 7ef344e. Display-only change in publish_html_plan: a charge span now ends at the last boundary from which SoC stays at the target, and both charge and export labels are judged on the span drawn instead of the whole window. I traced the split loop and the label scans against the span-drawing invariants (rowspan bookkeeping across the split, the export cut, mid-slot rows, the periods_left/plan-end cap, freeze windows, and the rowspan/skip handling on both the server HTML and the client renderer in web_helper.py), and re-derived each of the ten new test cases against both this code and main's window end - minute_now_align scan - they are consistent with the code, and the ones I could check by hand do fail on main via the mid-slot overshoot. The committed debug-case goldens compare plan windows only (test_single_debug.py), so they are not affected. 2 low findings inline, 1 note in the body.

Does this fully fix #5990? The PR fixes the plan-table labelling half. The 5 Nov triage comment on #5990 (comment 6668165463) attributed the all-day charge windows to auto-mode widening at fetch.py (rate_export_max > rate_max makes rate_import_cost_threshold = rate_max + 0.1, so every slot is a charge candidate - still present on this branch, confirmed at fetch.py:3561-3565). With this PR the same plan now reads Chrg then HoldChrg instead of one mislabelled block; if the reporter's complaint was the windows themselves (they expected Demand in the peak period), that part remains open and #5990 should not be closed on the label fix alone - worth checking against the reporter's rate_low_threshold setting when it merges.

Comment thread apps/predbat/output.py Resolved
Comment thread apps/predbat/output.py Resolved
@springfall2008 springfall2008 added BOT_CLEANUP Trigger: bot should address PR review feedback and CI failures, then commit and push and removed BOT_REVIEW Trigger an autotriage labels Nov 6, 2026
CI and others added 2 commits November 9, 2026 20:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Predbat Plan has continual Charge Slots to 100% in Peak Rate Period

2 participants