Skip to content

Commit 911ade7

Browse files
committed
Switch the JSON plan to be an attribute of the plan_html entity, based on feedback
1 parent faaedb1 commit 911ade7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

apps/predbat/predbat.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4172,7 +4172,7 @@ def get_html_plan_header(self, plan_debug):
41724172
html += "</tr>"
41734173
return html
41744174

4175-
def publish_json_plan(self, pv_forecast_minute_step, pv_forecast_minute_step10, load_minutes_step, load_minutes_step10, end_record):
4175+
def get_json_plan(self, pv_forecast_minute_step, pv_forecast_minute_step10, load_minutes_step, load_minutes_step10, end_record):
41764176
output = {}
41774177

41784178
plan_debug = self.get_arg("plan_debug")
@@ -4436,9 +4436,10 @@ def publish_json_plan(self, pv_forecast_minute_step, pv_forecast_minute_step10,
44364436
# output['raw']['load_minutes_step'] = load_minutes_step
44374437
# output['raw']['load_minutes_step10'] = load_minutes_step10
44384438

4439-
self.dashboard_item(self.prefix + ".plan_html", state="", attributes={"json": json.dumps(output), "friendly_name": "Plan in JSON", "icon": "mdi:web-box"})
4439+
return output
44404440

44414441
def publish_html_plan(self, pv_forecast_minute_step, pv_forecast_minute_step10, load_minutes_step, load_minutes_step10, end_record):
4442+
json_output = self.get_json_plan(pv_forecast_minute_step, pv_forecast_minute_step10, load_minutes_step, load_minutes_step10, end_record)
44424443
"""
44434444
Publish the current plan in HTML format
44444445
"""
@@ -4823,7 +4824,7 @@ def publish_html_plan(self, pv_forecast_minute_step, pv_forecast_minute_step10,
48234824
html += "<td bgcolor=" + carbon_color + "> " + str(carbon_str) + " </td>"
48244825
html += "</tr>"
48254826
html += "</table>"
4826-
self.dashboard_item(self.prefix + ".plan_html", state="", attributes={"html": html, "friendly_name": "Plan in HTML", "icon": "mdi:web-box"})
4827+
self.dashboard_item(self.prefix + ".plan_html", state="", attributes={"html": html, "json": json.dumps(json_output), "friendly_name": "Plan in HTML", "icon": "mdi:web-box"})
48274828
self.html_plan = html
48284829

48294830
def publish_rates(self, rates, export, gas=False):
@@ -8507,8 +8508,6 @@ def calculate_plan(self, recompute=True):
85078508

85088509
# HTML data
85098510
self.publish_html_plan(pv_forecast_minute_step, pv_forecast_minute10_step, load_minutes_step, load_minutes_step10, self.end_record)
8510-
# JSON data
8511-
self.publish_json_plan(pv_forecast_minute_step, pv_forecast_minute10_step, load_minutes_step, load_minutes_step10, self.end_record)
85128511

85138512
# Destroy pool
85148513
if self.pool:

0 commit comments

Comments
 (0)