Skip to content

Commit e1885c2

Browse files
committed
Early exit in iteration when current soc is higher than target_max_soc
1 parent 6727eda commit e1885c2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: source/inverter_charge_controller.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def start(self) -> None:
6363
first_iteration = False
6464
else:
6565
self._do_iteration()
66+
self.iteration_cache = {}
6667

6768
if self.next_price_minimum.has_to_be_rechecked:
6869
now = TimeHandler.get_time(sanitize_seconds=True)
@@ -124,6 +125,13 @@ def _do_iteration(self) -> None:
124125
current_state_of_charge = self.inverter.get_state_of_charge()
125126
self.log.info(f"The battery is currently is at {current_state_of_charge}")
126127

128+
if current_state_of_charge >= self.target_max_soc:
129+
self.log.info(
130+
f"The current state of charge ({current_state_of_charge}) is greater than the maximum allowed"
131+
f"state of charge ({self.target_max_soc}) --> No charging necessary/possible"
132+
)
133+
return
134+
127135
self.average_power_consumption = self._get_average_power_consumption()
128136
self.log.info(f"The average power consumption is {self.average_power_consumption}")
129137

@@ -165,8 +173,6 @@ def _do_iteration(self) -> None:
165173
minimum_of_soc_until_next_price_minimum,
166174
)
167175

168-
self.iteration_cache = {}
169-
170176
def coordinate_charging(
171177
self,
172178
current_state_of_charge: StateOfCharge,

0 commit comments

Comments
 (0)