@@ -121,12 +121,6 @@ def _do_iteration(self) -> None:
121
121
self .next_price_minimum = self ._get_next_price_minimum ()
122
122
self .log .info (f"The next price minimum is at { self .next_price_minimum } " )
123
123
124
- self .tibber_api_handler .set_maximum_charging_duration_of_current_energy_rate (current_energy_rate )
125
- self .log .info (
126
- f"The maximum charging duration of the current energy rate is "
127
- f"{ current_energy_rate .maximum_charging_duration } "
128
- )
129
-
130
124
current_state_of_charge = self .inverter .get_state_of_charge ()
131
125
self .log .info (f"The battery is currently is at { current_state_of_charge } " )
132
126
@@ -163,7 +157,6 @@ def _do_iteration(self) -> None:
163
157
"timestamp now" : str (timestamp_now ),
164
158
"next price minimum" : self .next_price_minimum ,
165
159
"next price minimum has to be rechecked" : self .next_price_minimum .has_to_be_rechecked ,
166
- "maximum charging duration" : current_energy_rate .format_maximum_charging_duration (),
167
160
"current state of charge" : current_state_of_charge ,
168
161
"average power consumption" : average_power_consumption .watts ,
169
162
"target min soc" : target_min_soc ,
@@ -186,7 +179,7 @@ def _do_iteration(self) -> None:
186
179
if charging_target_soc is None :
187
180
return
188
181
189
- self .handle_charging (charging_target_soc , current_energy_rate . maximum_charging_duration )
182
+ self .handle_charging (charging_target_soc )
190
183
191
184
self .iteration_cache = {}
192
185
@@ -292,20 +285,19 @@ def _calculate_target_soc(
292
285
293
286
return charging_target_soc
294
287
295
- def handle_charging (self , charging_target_soc : StateOfCharge , maximum_charging_duration : timedelta ) -> None :
288
+ def handle_charging (self , charging_target_soc : StateOfCharge ) -> None :
296
289
"""
297
290
Handles the charging process. This involves getting the energy bought before charging, charging the inverter,
298
291
getting the energy bought after charging, and updating the database with the consumed energy data.
299
292
300
293
Args:
301
294
charging_target_soc: Desired state of charge for the battery after charging.
302
- maximum_charging_duration: Maximum allowable duration for the charging process.
303
295
"""
304
296
energy_bought_before_charging = self .sems_portal_api_handler .get_energy_buy ()
305
297
timestamp_starting_to_charge = TimeHandler .get_time ()
306
298
self .log .debug (f"The amount of energy bought before charging is { energy_bought_before_charging } " )
307
299
308
- self ._charge_inverter (charging_target_soc , maximum_charging_duration )
300
+ self ._charge_inverter (charging_target_soc )
309
301
310
302
timestamp_ending_to_charge = TimeHandler .get_time ()
311
303
@@ -327,7 +319,7 @@ def handle_charging(self, charging_target_soc: StateOfCharge, maximum_charging_d
327
319
timestamp_starting_to_charge , timestamp_ending_to_charge , energy_bought
328
320
)
329
321
330
- def _charge_inverter (self , target_state_of_charge : StateOfCharge , maximum_charging_duration : timedelta ) -> None :
322
+ def _charge_inverter (self , target_state_of_charge : StateOfCharge ) -> None :
331
323
"""
332
324
Charges the inverter battery to the target state of charge within a specified maximum charging duration.
333
325
Monitors the charging progress at regular intervals and stops the charging process if specific conditions are
@@ -340,13 +332,10 @@ def _charge_inverter(self, target_state_of_charge: StateOfCharge, maximum_chargi
340
332
Args:
341
333
target_state_of_charge: The desired battery state of charge percentage to reach during the
342
334
charging process.
343
- maximum_charging_duration: The maximum duration allowed for the charging process to complete.
344
335
"""
345
336
charging_progress_check_interval = timedelta (minutes = 5 )
346
337
347
- maximum_end_charging_time = (
348
- TimeHandler .get_time (sanitize_seconds = True ).replace (minute = 0 ) + maximum_charging_duration
349
- )
338
+ maximum_end_charging_time = TimeHandler .get_time (sanitize_seconds = True ).replace (minute = 0 ) + timedelta (hours = 2 )
350
339
351
340
self .log .info ("Starting to charge" )
352
341
self .inverter .set_operation_mode (OperationMode .ECO_CHARGE )
@@ -367,8 +356,8 @@ def _charge_inverter(self, target_state_of_charge: StateOfCharge, maximum_chargi
367
356
# Can't set the mode of the inverter as it is unresponsive
368
357
break
369
358
370
- # Account for program execution times, this way the check happens at 05:00 and does not add up delays
371
- # (minor cosmetics)
359
+ # Account for program execution times, this way the check happens at 5-minute intervals and delays do not
360
+ # add up (minor cosmetics)
372
361
pause .seconds (charging_progress_check_interval .total_seconds () - TimeHandler .get_time ().second )
373
362
374
363
try :
0 commit comments