Take a copy of rates obtained via download_octopus_rates so saving sessions don't repeatedly increment them#3611
Merged
springfall2008 merged 2 commits intospringfall2008:mainfrom Mar 21, 2026
Conversation
…ssions don't repeatedly increment them When using rates_import_octopus_url/rates_export_octopus_url: - ```download_octopus_rates``` fetches the current cached import/export rates - ```load_saving_slot``` increments the rates *as stored in the cache* at the relevant times - these increases accumulate, and reset only when the cache is deemed stale - repeat until the saving session is over Solution -- take a copy of the cached import/export rates, so saving sessions affect only a local copy of the rates rather than the cached rates.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an Octopus URL rate-cache mutation bug where applying saving sessions would repeatedly increment the cached import/export rates across refresh cycles, causing the effective rates to drift upward until the cache expires.
Changes:
- Make
fetch_sensor_data()take a local copy of import rates returned fromdownload_octopus_rates()so saving-session adjustments don’t mutate the URL cache. - Make
fetch_sensor_data()take a local copy of export rates returned fromdownload_octopus_rates()for the same reason.
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.
When using rates_import_octopus_url/rates_export_octopus_url:
download_octopus_ratesfetches the current cached import/export ratesload_saving_slotincrements the rates as stored in the cache at the relevant timesSolution -- take a copy of the cached import/export rates, so saving sessions affect only a local copy of the rates rather than the cached rates.
(Happy to submit an issue with a log file evidencing the bug, if that's your preferred workflow.)