Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import os
import yaml

THIS_VERSION = "v7.14.40"
THIS_VERSION = "v7.14.41"
TIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z"
TIME_FORMAT_SECONDS = "%Y-%m-%dT%H:%M:%S.%f%z"
TIME_FORMAT_OCTOPUS = "%Y-%m-%d %H:%M:%S%z"
Expand Down Expand Up @@ -878,7 +878,7 @@ def __init__(self, base, id=0, quiet=False):
# Log inverter details
if not quiet:
self.base.log(
"New Inverter {} with soc_max {} kWh nominal_capacity {} kWh battery rate raw {} w charge rate {} kW discharge rate {} kW battery_rate_min {} w ac limit {} kW export limit {} kW reserve {} % current_reserve {} %".format(
"Inverter {} with soc_max {} kWh nominal_capacity {} kWh battery rate raw {} w charge rate {} kW discharge rate {} kW battery_rate_min {} w ac limit {} kW export limit {} kW reserve {} % current_reserve {} %".format(
self.id,
self.base.dp2(self.soc_max),
self.base.dp2(self.nominal_capacity),
Expand Down Expand Up @@ -8728,6 +8728,9 @@ def calculate_plan(self, recompute=True):
# HTML data
self.publish_html_plan(pv_forecast_minute_step, load_minutes_step, self.end_record)

# Return if we recomputed or not
return recompute

def reset_inverter(self):
"""
Reset inverter to safe mode
Expand Down Expand Up @@ -9056,7 +9059,7 @@ def execute_plan(self):

# Only set the reserve when we reach the desired percent
if (inverter.soc_percent > limit) or (not disabled_charge_window):
self.log("Adjust reserve to default as SOC {} % is above target {} %".format(inverter.soc_percent, limit))
self.log("Adjust reserve to default as SOC {} % is above target {} % or charging active".format(inverter.soc_percent, limit))
inverter.adjust_reserve(0)
else:
self.log("Adjust reserve to target charge {} % (set_reserve_enable is true)".format(limit))
Expand Down Expand Up @@ -9893,12 +9896,14 @@ def update_pred(self, scheduled=True):
self.log("Plan was last updated on {} and is now {} minutes old".format(self.plan_last_updated, self.dp1(plan_age_minutes)))

# Calculate the new plan (or re-use existing)
self.calculate_plan(recompute=recompute)
recompute = self.calculate_plan(recompute=recompute)

# Publish rate data
self.publish_rate_and_threshold()

# Execute the plan
# Execute the plan, re-read the inverter first if we had to calculate (as time passes during calculations)
if recompute:
self.fetch_inverter_data()
status, status_extra = self.execute_plan()

# If the plan was not updated, and the time has expired lets update it now
Expand All @@ -9912,7 +9917,9 @@ def update_pred(self, scheduled=True):
self.dp1(plan_age_minutes), self.calculate_plan_every
)
)
# Calculate an updated plan, fetch the inverter data again and execute the plan
self.calculate_plan(recompute=True)
self.fetch_inverter_data()
status, status_extra = self.execute_plan()
else:
self.log("Will not recompute the plan, it is {} minutes old and max age is {} minutes".format(self.dp1(plan_age_minutes), self.calculate_plan_every))
Expand Down