Skip to content

Commit

Permalink
Merge pull request #77 from InventoCasa/76-bug-line-289-min-to-max-me…
Browse files Browse the repository at this point in the history
…thod

fixed #76
  • Loading branch information
InventoCasa authored Jun 14, 2024
2 parents 84c8da2 + 2b2eb2e commit b8100a6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions PV_Excess_Control/pyscript/pv_excess_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def on_time():
if home_battery_level >= PvExcessControl.min_home_battery_level or not self._force_charge_battery():
# home battery charge is high enough to direct solar power to appliances, if solar power is higher than load power
# calc avg based on pv excess (solar power - load power) according to specified window
avg_excess_power = int(sum(PvExcessControl.pv_history[-inst.appliance_switch_interval:]) / min([1,inst.appliance_switch_interval]))
avg_excess_power = int(sum(PvExcessControl.pv_history[-inst.appliance_switch_interval:]) / max(1,inst.appliance_switch_interval))
log.debug(f'{log_prefix} Home battery charge is sufficient ({home_battery_level}/{PvExcessControl.min_home_battery_level} %)'
f' OR remaining solar forecast is higher than remaining capacity of home battery. '
f'Calculated average excess power based on >> solar power - load power <<: {avg_excess_power} W')
Expand All @@ -295,7 +295,7 @@ def on_time():
# home battery charge is not yet high enough OR battery force charge is necessary.
# Only use excess power (which would otherwise be exported to the grid) for appliance
# calc avg based on export power history according to specified window
avg_excess_power = int(sum(PvExcessControl.export_history[-inst.appliance_switch_interval:]) / min([1,inst.appliance_switch_interval]))
avg_excess_power = int(sum(PvExcessControl.export_history[-inst.appliance_switch_interval:]) / max(1,inst.appliance_switch_interval))
log.debug(f'{log_prefix} Home battery charge is not sufficient ({home_battery_level}/{PvExcessControl.min_home_battery_level} %), '
f'OR remaining solar forecast is lower than remaining capacity of home battery. '
f'Calculated average excess power based on >> export power <<: {avg_excess_power} W')
Expand Down

0 comments on commit b8100a6

Please sign in to comment.