From 2bcf412bb054d71349c0d2a8be874a6960b5ebee Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Sat, 14 Dec 2024 16:37:20 +0000 Subject: [PATCH 1/3] Restore old metric keep method --- apps/predbat/prediction.py | 8 ++++---- apps/predbat/unit_test.py | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/predbat/prediction.py b/apps/predbat/prediction.py index 54fad2796..532d38e58 100644 --- a/apps/predbat/prediction.py +++ b/apps/predbat/prediction.py @@ -808,12 +808,12 @@ def run_prediction(self, charge_limit, charge_window, export_window, export_limi diff = get_diff(battery_draw, pv_dc, pv_ac, load_yesterday, inverter_loss) # Metric keep - pretend the battery is empty and you have to import instead of using the battery - if soc < self.best_soc_keep and battery_draw > 0: + if soc < self.best_soc_keep: # Apply keep as a percentage of the time in the future so it gets stronger over an 4 hour period # Weight to 50% chance of the scenario - # keep_diff = max(get_diff(0, 0, pv_now, load_yesterday, inverter_loss), battery_draw) - # if keep_diff > 0: - metric_keep += rate_import[minute_absolute] * battery_draw * keep_minute_scaling + keep_diff = max(get_diff(0, 0, pv_now, load_yesterday, inverter_loss), battery_draw) + if keep_diff > 0: + metric_keep += rate_import[minute_absolute] * keep_diff * keep_minute_scaling if diff > 0: # Import # All imports must go to home (no inverter loss) or to the battery (inverter loss accounted before above) diff --git a/apps/predbat/unit_test.py b/apps/predbat/unit_test.py index ff20cd2f7..0c9ab8103 100644 --- a/apps/predbat/unit_test.py +++ b/apps/predbat/unit_test.py @@ -897,8 +897,8 @@ def run_execute_test( def run_single_debug(my_predbat, debug_file): print("**** Running debug test {} ****\n".format(debug_file)) re_do_rates = True - reset_load_model = True - load_override = 0.2 + reset_load_model = False + load_override = 1.0 reset_inverter(my_predbat) my_predbat.read_debug_yaml(debug_file) @@ -907,10 +907,10 @@ def run_single_debug(my_predbat, debug_file): my_predbat.fetch_config_options() # Force off combine export XXX: - print("Combined export slots {}".format(my_predbat.combine_export_slots)) + print("Combined export slots {} min_improvement_export {}".format(my_predbat.combine_export_slots, my_predbat.metric_min_improvement_export)) # my_predbat.combine_export_slots = False # my_predbat.best_soc_keep = 1.0 - my_predbat.metric_min_improvement_export = 5 + #my_predbat.metric_min_improvement_export = 5 if re_do_rates: # Set rate thresholds @@ -3392,7 +3392,7 @@ def run_model_tests(my_predbat): with_battery=True, discharge=0, battery_soc=10, - assert_keep=1 * import_rate * KEEP_SCALE, + assert_keep=14 * import_rate * 0.5 * KEEP_SCALE + 1 * import_rate * KEEP_SCALE, keep=1.0, ) failed |= simple_scenario( @@ -3405,7 +3405,7 @@ def run_model_tests(my_predbat): with_battery=True, discharge=0, battery_soc=10, - assert_keep=1 * import_rate * KEEP_SCALE, + assert_keep=14 * import_rate * 0.5 * KEEP_SCALE + 1 * import_rate * KEEP_SCALE, keep=1.0, save="test", ) @@ -3419,7 +3419,7 @@ def run_model_tests(my_predbat): with_battery=True, discharge=0, battery_soc=10, - assert_keep=1 * import_rate * KEEP_SCALE, + assert_keep=14 * import_rate * 0.5 * KEEP_SCALE + 1 * import_rate * KEEP_SCALE, keep=1.0, save="none", ) @@ -4064,7 +4064,7 @@ def run_model_tests(my_predbat): battery_size=10, keep=1.0, assert_final_iboost=0, - assert_keep=import_rate * 1 * KEEP_SCALE, + assert_keep=import_rate * 14 * 0.5 * KEEP_SCALE + import_rate * 1 * KEEP_SCALE, ) # Alternating high/low rates From b3271cb0b377fffcd6dd494be918bc56d4e97d8d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 16:38:44 +0000 Subject: [PATCH 2/3] [pre-commit.ci lite] apply automatic fixes --- apps/predbat/unit_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/predbat/unit_test.py b/apps/predbat/unit_test.py index 0c9ab8103..c4fd3c5b8 100644 --- a/apps/predbat/unit_test.py +++ b/apps/predbat/unit_test.py @@ -910,7 +910,7 @@ def run_single_debug(my_predbat, debug_file): print("Combined export slots {} min_improvement_export {}".format(my_predbat.combine_export_slots, my_predbat.metric_min_improvement_export)) # my_predbat.combine_export_slots = False # my_predbat.best_soc_keep = 1.0 - #my_predbat.metric_min_improvement_export = 5 + # my_predbat.metric_min_improvement_export = 5 if re_do_rates: # Set rate thresholds From 980c2eba2a80acfcc842bebfd0b1d913c1dcc3da Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Sat, 14 Dec 2024 16:39:03 +0000 Subject: [PATCH 3/3] Version --- apps/predbat/predbat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index 59632d2ba..1f7608e38 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -38,7 +38,7 @@ import asyncio import json -THIS_VERSION = "v8.8.7" +THIS_VERSION = "v8.8.8" # fmt: off PREDBAT_FILES = ["predbat.py", "config.py", "prediction.py", "gecloud.py","utils.py", "inverter.py", "ha.py", "download.py", "unit_test.py", "web.py", "predheat.py", "futurerate.py", "octopus.py", "solcast.py","execute.py", "plan.py", "fetch.py", "output.py", "userinterface.py"]