Skip to content

Commit

Permalink
[pre-commit.ci lite] apply automatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci-lite[bot] authored Jan 11, 2025
1 parent f98e048 commit 398785c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
40 changes: 21 additions & 19 deletions apps/predbat/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,34 @@ def execute_plan(self):
self.log("Inverter {} Charge window will be: {} - {} - current soc {} target {}".format(inverter.id, charge_start_time, charge_end_time, inverter.soc_percent, self.charge_limit_percent_best[0]))
# Are we actually charging?
if self.minutes_now >= minutes_start and self.minutes_now < minutes_end:

target_soc = self.charge_limit_percent_best[0] if self.charge_limit_best != self.reserve else self.soc_kw
inv_target_soc = self.adjust_battery_target_multi(inverter, target_soc, True, False, check=True)

new_charge_rate, new_charge_rate_real = find_charge_rate(
self.minutes_now,
inverter.soc_kw,
window,
inv_target_soc * inverter.soc_max / 100.0,
inverter.battery_rate_max_charge,
inverter.soc_max,
self.battery_charge_power_curve,
self.set_charge_low_power,
self.charge_low_power_margin,
self.battery_rate_min,
self.battery_rate_max_scaling,
self.battery_loss,
self.log,
inverter.battery_temperature,
self.battery_temperature_discharge_curve
)
self.minutes_now,
inverter.soc_kw,
window,
inv_target_soc * inverter.soc_max / 100.0,
inverter.battery_rate_max_charge,
inverter.soc_max,
self.battery_charge_power_curve,
self.set_charge_low_power,
self.charge_low_power_margin,
self.battery_rate_min,
self.battery_rate_max_scaling,
self.battery_loss,
self.log,
inverter.battery_temperature,
self.battery_temperature_discharge_curve,
)
new_charge_rate = int(new_charge_rate * MINUTE_WATT)
current_charge_rate = inverter.get_current_charge_rate()

self.log("Inverter {} Target SOC {} (this inverter {}) Battery temperature {} Select charge rate {}w (real {}w) current charge rate {}".format(inverter.id, target_soc, inv_target_soc, inverter.battery_temperature, new_charge_rate, new_charge_rate_real * MINUTE_WATT, current_charge_rate))
self.log(
"Inverter {} Target SOC {} (this inverter {}) Battery temperature {} Select charge rate {}w (real {}w) current charge rate {}".format(
inverter.id, target_soc, inv_target_soc, inverter.battery_temperature, new_charge_rate, new_charge_rate_real * MINUTE_WATT, current_charge_rate
)
)

# Adjust charge rate if we are more than 10% out or we are going back to Max charge rate
max_rate = inverter.battery_rate_max_charge * MINUTE_WATT
Expand Down Expand Up @@ -681,7 +684,6 @@ def fetch_inverter_data(self, create=True):
self.current_charge_limit = calc_percent_limit(self.current_charge_limit_kwh, self.soc_max)
self.battery_temperature += inverter.battery_temperature


# Work out battery temperature
self.battery_temperature = int(dp0(self.battery_temperature / self.num_inverters))

Expand Down
1 change: 0 additions & 1 deletion apps/predbat/inverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ def __init__(self, base, id=0, quiet=False, rest_postCommand=None, rest_getData=

ivtime = self.base.get_arg("inverter_time", index=self.id, default=None)


# Battery cannot be zero size
if self.soc_max <= 0:
self.base.log("Error: Reported battery size from REST is {}, but it must be >0".format(self.soc_max))
Expand Down

0 comments on commit 398785c

Please sign in to comment.