Skip to content

Commit

Permalink
Merge branch 'springfall2008:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gcoan authored Dec 3, 2023
2 parents 82abdf0 + c2304e1 commit b6327e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion apps/predbat/config/apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ pred_bat:
# - 200

# Workaround to limit the maximum reserve setting, some inverters won't allow 100% to be set
# inverter_reserve_max : 99
# Comment out if your inverter allows 100%
inverter_reserve_max : 98

# Some batteries tail off their charge rate at high soc%
# enter the charging curve here as a % of the max charge rate for each soc percentage.
Expand Down
17 changes: 14 additions & 3 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import appdaemon.plugins.hass.hassapi as hass
import adbase as ad

THIS_VERSION = "v7.13.21"
THIS_VERSION = "v7.13.22"
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 @@ -7945,8 +7945,9 @@ def calculate_plan(self, recompute=True):

# Plan is now valid
self.plan_valid = True
self.plan_last_updated = self.now_utc
self.plan_last_updated_minutes = self.minutes_now
if recompute:
self.plan_last_updated = self.now_utc
self.plan_last_updated_minutes = self.minutes_now

if self.calculate_best:
# Final simulation of best, do 10% and normal scenario
Expand Down Expand Up @@ -8041,6 +8042,11 @@ def execute_plan(self):
)
minutes_start = inverter.charge_start_time_minutes

# Avoid having too long a period to configure as registers only support 24-hours
if (minutes_start < self.minutes_now) and ((minutes_end - minutes_start) >= 24 * 60):
minutes_start = int(self.minutes_now / 30) * 30
self.log("Move on charge window start time to avoid wrap - new start {}".format(self.time_abs_str(minutes_start)))

# Check if end is within 24 hours of now and end is in the future
if (minutes_end - self.minutes_now) < 24 * 60 and minutes_end > self.minutes_now:
charge_start_time = self.midnight_utc + timedelta(minutes=minutes_start)
Expand Down Expand Up @@ -8127,6 +8133,11 @@ def execute_plan(self):
)
minutes_start = inverter.discharge_start_time_minutes

# Avoid having too long a period to configure as registers only support 24-hours
if (minutes_start < self.minutes_now) and ((minutes_end - minutes_start) >= 24 * 60):
minutes_start = int(self.minutes_now / 30) * 30
self.log("Move on discharge window start time to avoid wrap - new start {}".format(self.time_abs_str(minutes_start)))

discharge_start_time = self.midnight_utc + timedelta(minutes=minutes_start)
discharge_end_time = self.midnight_utc + timedelta(minutes=(minutes_end + 1)) # Add in 1 minute margin to allow Predbat to restore ECO mode
discharge_soc = (self.discharge_limits_best[0] * self.soc_max) / 100.0
Expand Down

0 comments on commit b6327e3

Please sign in to comment.