Repository navigation
fix(octopus): keep Intelligent dispatch markers when export/gas rates are fetched (#5286) - #5290
Merged
Merged
Conversation
… are fetched (#5286) fetch_octopus_rates() replaced self.io_adjusted on every call, so the export and gas fetches that follow the import fetch reset it to {} - every BottlecapDave IOG user with metric_octopus_export or metric_octopus_gas set lost all is_intelligent_adjusted markers. Regression from #2826, which dropped the old "only when adjust_key is set" guard. Among other things this left dynamic_load_car_strip_feed_rates() with nothing to strip, so a car cancelled by #5229 still left its dispatch priced cheap and the house battery was planned into it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…its own import rates (#5286) With io_adjusted no longer wiped by the export fetch, a compared tariff with its own import rates (URL, flat rates_import, Energi Data Service, Strømligning) would inherit the live tariff's Intelligent Octopus dispatch markers, and rate_replicate(), the PV10 prediction and the plan would treat its minutes as dispatches. Each tariff now starts with none; an Octopus import fetch sets its own, and a tariff left on the live import rates (no import source, or a bad entity id) gets a copy of the live markers. run_all() restores the live markers afterwards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
springfall2008
marked this pull request as ready for review
September 28, 2026 18:08
This was referenced Sep 29, 2026
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.
Addresses #5286. Draft: being dogfooded on a real BottlecapDave (BDC) + Intelligent Octopus Go system before review.
Problem
Since #2826 (v8.27.0, Oct 2025),
fetch_octopus_rates()has replacedself.io_adjustedon every call.fetch_sensor_data()calls it for import rates (withadjust_key="is_intelligent_adjusted") and afterwards formetric_octopus_gasandmetric_octopus_export(without). Those later calls resetio_adjustedto{}. Before #2826 the assignment only happened whenadjust_keywas set.So every BDC Intelligent Octopus user with an export or gas rate sensor has had no dispatch markers at all, even though BDC sends
is_intelligent_adjusted: true. This was confirmed on a second BDC 19.1.0 install: HA's storedcurrent_day_rates/next_day_ratesevents carry the flag, while every Predbat debug dump hasio_adjusted: {}.In #5286 this left
dynamic_load_car_strip_feed_rates()(#5229) with nothing to strip. The car's slots were cancelled, but the dispatch stayed priced at 6.9p, and the house battery was planned into it at 15:00 and 15:30.Changes
octopus.py:fetch_octopus_rates()only replacesself.io_adjustedwhen called withadjust_key. This restores the pre-Refactor minute_data to utils and fix some issues with energy dashboard #2826 behaviour.compare.py: now that the markers survive, tariff comparison must not hand the live tariff's markers to a compared tariff that has its own import rates. Each tariff now starts with none. An Octopus import fetch sets its own. A tariff left on the live import rates (no import source, or a bad entity id) gets a copy of the live markers.run_all()restores the live markers afterwards. Before this PR, the export fetch wiped them by accident.Behaviour change: please read
This switches dispatch-aware logic back on for every affected BDC user. All of it was built or tuned while it was dormant for them, and tested only with hand-set
io_adjusted:rate_replicate(), which prices dispatch minutes atrate_maxwhen copying rates into later daysplan.pyprediction.py/prediction_kernel.pyPlans for these users will change. The golden
coverage/casesall haveio_adjusted: {}, so they don't show this.Testing
test_fetch_octopus_ratesTest 5a: an export fetch after an import fetch keeps the import's markers. It fails onmain.test_compareT26: checks which markers a compared tariff with its own import rates, an existing-rates tariff and a bad-entity tariff each end up with, and thatrun_all()restores them. Each assertion was checked to fail when its part of the fix is removed../run_all --quickandrun_pre_commitpass on each commit.fetch_sensor_data()(flagged import, then export, then a cancelled car, ending with the dispatch at full price).Follow-ups, not in this PR
dynamic_load_car_strip_feed_rates(), so a compared IOG tariff keeps the markers of a cancelled car's dispatches. This predates this PR.run_all()doesn't restorerate_import/rate_export/ thresholds after the loop. This predates this PR and is harmless because the next cycle rebuilds them.🤖 Generated with Claude Code