From d95f6346fcb262058f2df41b50661277d60602fb Mon Sep 17 00:00:00 2001
From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com>
Date: Sun, 4 Feb 2024 16:00:10 +0000
Subject: [PATCH 1/2] Show creation time on html plan
---
apps/predbat/predbat.py | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py
index d75c3fa82..a1ad12800 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,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
@@ -6473,12 +6474,11 @@ def adjust_symbol(self, adjust_type):
symbol = "?"
return symbol
- def publish_html_plan(self, pv_forecast_minute_step, load_minutes_step, end_record):
+ def get_html_plan_header(self, plan_debug):
"""
- Publish the current plan in HTML format
+ Returns the header row for the HTML plan.
"""
- plan_debug = self.get_arg("plan_debug")
- html = "
"
+ html = ""
html += ""
html += "| Time | "
if plan_debug:
@@ -6499,7 +6499,18 @@ def publish_html_plan(self, pv_forecast_minute_step, load_minutes_step, end_reco
html += "Cost | "
html += "Total | "
html += "
"
+ return html
+ def publish_html_plan(self, pv_forecast_minute_step, load_minutes_step, end_record):
+ """
+ Publish the current plan in HTML format
+ """
+ plan_debug = self.get_arg("plan_debug")
+ html = ""
+ html += ""
+ html += "| last updated: {} | ".format(self.now_utc.strftime("%Y-%m-%d %H:%M:%S"))
+ html += "
"
+ html += self.get_html_plan_header(plan_debug)
minute_now_align = int(self.minutes_now / 30) * 30
end_plan = min(end_record, self.forecast_minutes) + minute_now_align
rowspan = 0
@@ -11097,9 +11108,9 @@ async 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 52bbe3ccc98569776011ada47a69fa4395080b43 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 16:01:54 +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 a1ad12800..02756cbee 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
@@ -11108,9 +11107,9 @@ async 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", {})