Skip to content

Commit

Permalink
Freeze export was not working due to min improvement (#1998)
Browse files Browse the repository at this point in the history
* Freeze export was not working due to min improvement

#1997

* [pre-commit.ci lite] apply automatic fixes

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
  • Loading branch information
springfall2008 and pre-commit-ci-lite[bot] authored Feb 11, 2025
1 parent ae3f700 commit d17cb8c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/predbat/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,11 +1244,13 @@ def rate_replicate(self, rates, rate_io={}, is_import=True, is_gas=False):
rate_offset = rate_last

# Only offset once not every day
futurerate_adjust_import = self.get_arg("futurerate_adjust_import", False)
futurerate_adjust_export = self.get_arg("futurerate_adjust_export", False)
if minute_mod not in adjusted_rates:
if is_import and self.get_arg("futurerate_adjust_import", False) and (minute in self.future_energy_rates_import) and (minute_mod in self.future_energy_rates_import):
if is_import and futurerate_adjust_import and (minute in self.future_energy_rates_import) and (minute_mod in self.future_energy_rates_import):
rate_offset = self.future_energy_rates_import[minute]
adjust_type = "future"
elif (not is_import) and (not is_gas) and self.get_arg("futurerate_adjust_export", False) and (minute in self.future_energy_rates_export) and (minute_mod in self.future_energy_rates_export):
elif (not is_import) and (not is_gas) and futurerate_adjust_export and (minute in self.future_energy_rates_export) and (minute_mod in self.future_energy_rates_export):
rate_offset = max(self.future_energy_rates_export[minute], 0)
adjust_type = "future"
elif is_import:
Expand Down
2 changes: 2 additions & 0 deletions apps/predbat/octopus.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def download_octopus_rates(self, url):
Retry 3 times and then throw error
"""

self.log("Download Octopus rates from {}".format(url))

# Check the cache first
now = datetime.now()
if url in self.octopus_url_cache:
Expand Down
5 changes: 5 additions & 0 deletions apps/predbat/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,11 +1403,16 @@ def optimise_export(self, window_n, record_charge_windows, try_charge_limit, cha
window_key = str(int(this_export_limit)) + "_" + str(window_size)
window_results[window_key] = [metric, cost]

# Only select an export if it makes a notable improvement has defined by min_improvement (divided in M windows)
if all_n:
min_improvement_scaled = self.metric_min_improvement_export
else:
min_improvement_scaled = self.metric_min_improvement_export * window_size / 30.0

# Scale back in the case of freeze export as improvements will be smaller
if this_export_limit == 99:
min_improvement_scaled *= 0.2

# Only select an export if it makes a notable improvement has defined by min_improvement (divided in M windows)
if ((metric + min_improvement_scaled) <= off_metric) and (metric <= best_metric):
best_metric = metric
Expand Down

0 comments on commit d17cb8c

Please sign in to comment.