From 13ed1700afcd458a1d8f2d24f1f186c93e32b714 Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Sun, 4 Feb 2024 09:29:42 +0000 Subject: [PATCH 1/2] Fix units on calculate plan every https://github.com/springfall2008/batpred/issues/708 --- apps/predbat/predbat.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index 39c5fb85a..ad17b1476 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -21,7 +21,7 @@ import requests import yaml -THIS_VERSION = "v7.15.12" +THIS_VERSION = "v7.15.13" PREDBAT_FILES = ["predbat.py"] TIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z" TIME_FORMAT_SECONDS = "%Y-%m-%dT%H:%M:%S.%f%z" @@ -512,7 +512,7 @@ "min": 5, "max": 60, "step": 5, - "unit": "kWh", + "unit": "minutes", "icon": "mdi:clock-end", "enable": "expert_mode", "default": 10, @@ -4370,7 +4370,7 @@ def find_charge_window_optimised(self, charge_windows): for window_n in range(len(charge_windows)): for minute in range(charge_windows[window_n]["start"], charge_windows[window_n]["end"], PREDICT_STEP): charge_window_optimised[minute] = window_n - return charge_window_optimised + return charge_window_optimised def run_prediction(self, charge_limit, charge_window, discharge_window, discharge_limits, load_minutes_step, pv_forecast_minute_step, end_record, save=None, step=PREDICT_STEP): """ @@ -4471,6 +4471,7 @@ def run_prediction(self, charge_limit, charge_window, discharge_window, discharg if self.set_reserve_enable: reserve_expected = max(charge_limit_n, self.reserve) + # Add in standing charge, only for the final plan when we save the results if (minute_absolute % (24 * 60)) < step and (save in ["best", "base", "base10", "best10"]): metric += self.metric_standing_charge @@ -11058,9 +11059,9 @@ def select_event(self, event, data, kwargs): None Description: - This method is used to handle Home Assistant input select updates. - It extracts the necessary information from the data and performs different actions based on the selected option. - The actions include calling update service, saving and restoring settings, performing manual selection, and exposing configuration. + This method is used to handle Home Assistant input select updates. + It extracts the necessary information from the data and performs different actions based on the selected option. + The actions include calling update service, saving and restoring settings, performing manual selection, and exposing configuration. After performing the actions, it triggers an update by setting update_pending flag to True and plan_valid flag to False. """ service_data = data.get("service_data", {}) From a9660efd1496de36789f371f442365ec8d1a3d27 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 09:31:10 +0000 Subject: [PATCH 2/2] [pre-commit.ci lite] apply automatic fixes --- apps/predbat/predbat.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index ad17b1476..fb554b48b 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -4370,7 +4370,7 @@ def find_charge_window_optimised(self, charge_windows): for window_n in range(len(charge_windows)): for minute in range(charge_windows[window_n]["start"], charge_windows[window_n]["end"], PREDICT_STEP): charge_window_optimised[minute] = window_n - return charge_window_optimised + return charge_window_optimised def run_prediction(self, charge_limit, charge_window, discharge_window, discharge_limits, load_minutes_step, pv_forecast_minute_step, end_record, save=None, step=PREDICT_STEP): """ @@ -4471,7 +4471,6 @@ def run_prediction(self, charge_limit, charge_window, discharge_window, discharg if self.set_reserve_enable: reserve_expected = max(charge_limit_n, self.reserve) - # Add in standing charge, only for the final plan when we save the results if (minute_absolute % (24 * 60)) < step and (save in ["best", "base", "base10", "best10"]): metric += self.metric_standing_charge @@ -11059,9 +11058,9 @@ def select_event(self, event, data, kwargs): None Description: - This method is used to handle Home Assistant input select updates. - It extracts the necessary information from the data and performs different actions based on the selected option. - The actions include calling update service, saving and restoring settings, performing manual selection, and exposing configuration. + This method is used to handle Home Assistant input select updates. + It extracts the necessary information from the data and performs different actions based on the selected option. + The actions include calling update service, saving and restoring settings, performing manual selection, and exposing configuration. After performing the actions, it triggers an update by setting update_pending flag to True and plan_valid flag to False. """ service_data = data.get("service_data", {})