Skip to content

Commit cabef04

Browse files
Improve variable naming in midnight crossing fix
Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com>
1 parent a0dd8be commit cabef04

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎apps/predbat/execute.py‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ def execute_plan(self):
8787
# Span midnight allowed?
8888
if not inverter.inv_can_span_midnight:
8989
# Convert to datetime first to check if it actually crosses midnight
90-
charge_start_time_temp = self.midnight_utc + timedelta(minutes=minutes_start)
91-
charge_end_time_temp = self.midnight_utc + timedelta(minutes=minutes_end)
90+
charge_start_datetime = self.midnight_utc + timedelta(minutes=minutes_start)
91+
charge_end_datetime = self.midnight_utc + timedelta(minutes=minutes_end)
9292

9393
# Only cap if the dates are different (actually crossing midnight)
94-
if charge_start_time_temp.date() != charge_end_time_temp.date():
94+
if charge_start_datetime.date() != charge_end_datetime.date():
9595
# Cap to end of start date (23:59 on the same day as start)
96-
end_of_start_date = charge_start_time_temp.replace(hour=23, minute=59, second=0, microsecond=0)
96+
end_of_start_date = charge_start_datetime.replace(hour=23, minute=59, second=0, microsecond=0)
9797
minutes_end = int((end_of_start_date - self.midnight_utc).total_seconds() / 60)
9898

9999
# Are we currently in the export window?
@@ -295,13 +295,13 @@ def execute_plan(self):
295295
# Span midnight allowed?
296296
if not inverter.inv_can_span_midnight:
297297
# Convert to datetime first to check if it actually crosses midnight
298-
discharge_start_time_temp = self.midnight_utc + timedelta(minutes=minutes_start)
299-
discharge_end_time_temp = self.midnight_utc + timedelta(minutes=minutes_end)
298+
discharge_start_datetime = self.midnight_utc + timedelta(minutes=minutes_start)
299+
discharge_end_datetime = self.midnight_utc + timedelta(minutes=minutes_end)
300300

301301
# Only cap if the dates are different (actually crossing midnight)
302-
if discharge_start_time_temp.date() != discharge_end_time_temp.date():
302+
if discharge_start_datetime.date() != discharge_end_datetime.date():
303303
# Cap to end of start date (23:59 on the same day as start)
304-
end_of_start_date = discharge_start_time_temp.replace(hour=23, minute=59, second=0, microsecond=0)
304+
end_of_start_date = discharge_start_datetime.replace(hour=23, minute=59, second=0, microsecond=0)
305305
minutes_end = int((end_of_start_date - self.midnight_utc).total_seconds() / 60)
306306
export_adjust = 0
307307

0 commit comments

Comments
 (0)