Repository navigation
fix(octopus): count the Intelligent daily cap in dispatch minutes, not half-hour blocks - #5512
Open
springfall2008 wants to merge 5 commits into
Open
springfall2008 wants to merge 5 commits into
springfall2008 wants to merge 5 commits into
Conversation
…t half-hour blocks (#5510) rate_add_io_slots() charged one 30-minute block per half hour a dispatch touched and load_octopus_slots() charged max(1, blocks spanned) per dispatch, so a 10-minute dispatch used 30 minutes of the cap and the two counters disagreed. Both now charge the dispatch's own minutes, as Octopus sends them for a completed dispatch and as planned for one still to come, through one shared helper. octopus_slot_max stays in 30-minute slots in apps.yaml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…th counters (#5510) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Active zero-kWh dispatches still consume different cap durations in the rate and car-plan counters.
1 open finding
What changed in this PR
Fixes #5510 by accounting for Octopus Intelligent caps in dispatch minutes rather than rounded half-hour blocks.
Changes:
- Adds shared minute-based cap accounting.
- Aligns rate and car-plan behavior and updates tests.
- Clarifies configuration documentation.
| File | Description |
|---|---|
apps/predbat/octopus.py |
Implements minute-based cap accounting. |
apps/predbat/tests/test_rate_add_io_slots.py |
Adds cap regression cases. |
apps/predbat/tests/test_octopus_slots.py |
Updates car-plan expectations. |
docs/car-charging.md |
Documents minute-based accounting. |
docs/apps-yaml.md |
Clarifies configuration units. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…its start (#5510) load_octopus_slots() moved the start of a running dispatch with zero kWh to now before charging the daily cap, so the car plan counted only what was left of it while rate_add_io_slots() counted the whole dispatch. The part already gone is now kept as a part with no load: it goes through the same overlap handling, uses the budget and emits no car slot. Eligibility and the budget's midday-to-midday period now go by the whole dispatch for every part of it, as they do in the rates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This is an automated draft PR generated from issue #5510 — a maintainer should review it before merging.
Fixes #5510
Summary
The Octopus Intelligent daily cap (
octopus_slot_max, 6 hours on IOG-SMB) was counted in 30-minute blocks rounded outwards, so a 10-minute dispatch used 30 minutes of it, and the two counters disagreed with each other. Both now count the dispatch's own minutes:rate_add_io_slots()(rates) andload_octopus_slots()(car plan) now charge the budget through one shared helper,take_cap_minutes().octopus_slot_maxis still set in 30-minute slots inapps.yamland multiplied out internally, so existing configs are unchanged.Behaviour changes to check
rate_add_io_slots()now takes dispatches earliest first, asload_octopus_slots()already did, so the budget goes to the same dispatches in both. It used to take them in the order given.Octopus: Intelligent slot minutes for day N: X of Y max, in minutes.Testing
test_rate_add_io_slots.py(run_cap_minutes_tests), each run through both counters: a short completed dispatch, two dispatches in one half hour, overlapping completed and planned dispatches, and a dispatch that crosses the end of the budget.octopus.pyreverted,rate_add_io_slotsfails on all four new cases (rates and car plan); with the fix,rate_add_io_slotsandoctopus_slotsboth pass.test_octopus_slots.pythat encoded block counting were updated: eight 60-minute dispatches from 14:05 used to hit the cap after four (three blocks each) and now hit it after six.unit_test.py --quick: all tests passed (4 slow tests skipped).Notes
load_octopus_slots()clamps dispatches to today, so it does not see the part of the current midday-to-midday period that fell before midnight;rate_add_io_slots()does.octopus_slot_low_rate: falsethe car plan counter does not run at all.impactreports no callers for either function, because they are reached through thePredBatmixin. By search the callers arefetch.py(both) andoutput.py(load_octopus_slots());detect_changesrates the change medium.🤖 Generated with Claude Code