fix: rate_min_base/rate_max_base computed from raw sparse fetch, not the gap-filled curve - #4553
Open
chalfontchubby wants to merge 1 commit into
Open
fix: rate_min_base/rate_max_base computed from raw sparse fetch, not the gap-filled curve#4553chalfontchubby wants to merge 1 commit into
chalfontchubby wants to merge 1 commit into
Conversation
…ve, not the raw sparse fetch (#4544) rate_min_base/rate_max_base were captured from a scan of the raw import rate dict before rate_replicate() ran. For a tariff whose forward-fetch window is short (e.g. Kraken/E.ON Next Drive Smart, a fixed day/night product where the raw fetch only exposes the currently-active segment), the scan only ever saw the known segment and locked in the wrong "true" min/max for the day - rate_add_io_slots() then stamped IOG/SmartFlex dispatch slots with that stale value instead of the tariff's real off-peak price, showing as "Predbat charges the car at the high import rate". New rate_base_min_max() helper replicates first (mirroring how rate_export_base is already built downstream of rate_replicate() on the export side) and scans the result, so a segment that hasn't started yet but is recoverable from history is reflected correctly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
Fixes #4544 - Predbat charging the car at the "high" import rate instead of the tariff's real off-peak price.
rate_min_base/rate_max_basewere scanned from the raw import rate dict beforerate_replicate()ran. For a tariff whose raw fetch only exposes the currently-active segment forward of "now" (confirmed via the reporter's debug.yaml: a fixed day/night Kraken/E.ON Next Drive Smart product,rates_mingenuinely8.0pbutrate_min_baselocked at31.18p, equal torate_max_base), the scan simply never saw the cheaper segment that hadn't started yet.rate_add_io_slots()'soctopus_slot_low_rate=Truepath stamps IOG/SmartFlex dispatch slots withrate_min_baseas the "low" price - so those slots got priced at the tariff's peak rate instead, making the optimiser see no benefit to charging the battery during them.rate_base_min_max()helper (fetch.py) replicates the raw rates first and scans the result, mirroring howrate_export_baseis already built downstream ofrate_replicate()on the export side (the export side never had this bug).Test plan
rate_base_min_maxsub-test added totest_rate_replicate_missing_slots.py, reproducing the reported tariff's raw-vs-gap-filled scan directly - fails onmain(well, would, ifrate_base_min_maxexisted there) and passes with the fix../run_all --quick- full suite green, including the random scenario regression (matches committed baseline across all 320 compared fields)../run_pre_commitclean.🤖 Generated with Claude Code