Skip to content

Commit

Permalink
[ skip ci ] reduce max state of charge needed in the winter months
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaDodds committed Nov 3, 2024
1 parent 5413d14 commit 4f66162
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 0 additions & 2 deletions lib/energy_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def schedule_tasks():
scheduler.every().hour.at(":00").do(manage_sale_of_stored_energy_to_the_grid)

# Grid Charging Scheduled Tasks
# scheduler.every().day.at("13:10").do(publish_mqtt_trigger) # when next day prices are published each day
# scheduler.every().day.at("13:30").do(set_charging_schedule, caller="TaskScheduler()", silent=True)
scheduler.every().day.at("09:30").do(set_charging_schedule, caller="TaskScheduler()", silent=True)
scheduler.every().day.at("00:10").do(set_charging_schedule, caller="TaskScheduler()", silent=True)

Expand Down
21 changes: 18 additions & 3 deletions lib/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,29 @@ def get_seasonally_adjusted_max_charge_slots(batt_soc: float, pv_production_rema
to the batt_soc.
"""

winter_months = [9, 10, 11, 12, 1, 2, 3]

if pv_production_remaining:
# convert ov_forecasted from kWh to a percentage assuming battery capacity of 40kWh
# convert pv_forecasted from kWh to a percentage assuming battery capacity of 40kWh
pv_production_remaining = round((pv_production_remaining / 40) * 100, 2)

current_month = datetime.now().month

if current_month in [9, 10, 11, 12, 1, 2, 3]:
return max(0, calculate_max_charge_slots_needed(batt_soc + pv_production_remaining))
# Set the maximum target state of charge to 75% if in the specified months
if current_month in winter_months:
max_target_soc = 75.0
else:
max_target_soc = 100.0

# Calculate the combined state of charge including PV production
combined_soc = batt_soc + pv_production_remaining

# Ensure we do not exceed the max target SOC
if combined_soc > max_target_soc:
combined_soc = max_target_soc

if current_month in winter_months:
return max(0, calculate_max_charge_slots_needed(combined_soc))

return 0

Expand Down

0 comments on commit 4f66162

Please sign in to comment.