Skip to content

Commit c9c38cb

Browse files
Change some log strings to proper dates
1 parent 7e52ce3 commit c9c38cb

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

predbat.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,12 @@ def time_now_str(self):
579579
"""
580580
return (self.midnight + timedelta(minutes=self.minutes_now)).strftime("%H:%M:%S")
581581

582+
def time_abs_str(self, minute):
583+
"""
584+
Return time absolute as human string
585+
"""
586+
return (self.midnight + timedelta(minutes=minute)).strftime("%m-%d %H:%M:%S")
587+
582588
def rate_replicate(self, rates):
583589
"""
584590
We don't get enough hours of data for Octopus, so lets assume it repeats until told others
@@ -670,7 +676,7 @@ def basic_rates(self, info):
670676
if end_minutes <= start_minutes:
671677
end_minutes += 24*60
672678

673-
self.log("Found rate {} {} to {} minutes".format(rate, start_minutes, end_minutes))
679+
# self.log("Found rate {} {} to {} minutes".format(rate, start_minutes, end_minutes))
674680
for minute in range(start_minutes, end_minutes):
675681
rates[minute % (24*60)] = rate
676682

@@ -777,7 +783,7 @@ def rate_scan(self, rates, octopus_slots):
777783
rate_low_end = window['end']
778784
rate_low_average = window['average']
779785

780-
self.log("Low rate period {}-{} @{} !".format(rate_low_start, rate_low_end, rate_low_average))
786+
self.log("Low rate period {} to {} @{} !".format(self.time_abs_str(rate_low_start), self.time_abs_str(rate_low_end), rate_low_average))
781787

782788
rate_low_start_date = self.midnight_utc + timedelta(minutes=rate_low_start)
783789
rate_low_end_date = self.midnight_utc + timedelta(minutes=rate_low_end)
@@ -1167,7 +1173,7 @@ def update_pred(self):
11671173
self.charge_limit_percent_best = [current_charge_limit for i in range(0, len(self.charge_window_best))]
11681174

11691175
self.charge_rate = float(self.get_state(self.get_arg('charge_rate', indirect=False), attribute='max')) / 1000.0 / 60.0
1170-
self.log("Charge settings are: {}-{} limit {} power {} (per minute)".format(str(self.charge_start_time_minutes), str(self.charge_end_time_minutes), str(self.charge_limit[0]), str(self.charge_rate)))
1176+
self.log("Charge settings are: {}-{} limit {} power {} (per minute)".format(self.time_abs_str(self.charge_start_time_minutes), self.time_abs_str(self.charge_end_time_minutes), str(self.charge_limit[0]), str(self.charge_rate)))
11711177

11721178
# battery max discharge rate
11731179
self.discharge_rate = float(self.get_state(self.get_arg('discharge_rate', indirect=False), attribute='max')) / 1000.0 / 60.0
@@ -1245,7 +1251,7 @@ def update_pred(self):
12451251
for windows in self.charge_window_best:
12461252
if minutes_end == windows['start']:
12471253
minutes_end = windows['end']
1248-
self.log("Combine window with next window {}-{}".format(windows['start'], windows['end']))
1254+
self.log("Combine window with next window {}-{}".format(self.time_abs_str(windows['start']), self.time_abs_str(windows['end'])))
12491255

12501256
# Avoid adjust avoid start time forward when it's already started
12511257
if (self.charge_start_time_minutes < self.minutes_now) and (self.minutes_now >= minutes_start):
@@ -1263,10 +1269,10 @@ def update_pred(self):
12631269
(minutes_start - self.minutes_now) <= self.set_window_minutes or
12641270
(self.charge_start_time_minutes - self.minutes_now) <= self.set_window_minutes
12651271
):
1266-
self.log("Configurating charge window now (now {} target set_window_minutes {} charge start time {}".format(self.minutes_now, self.set_window_minutes, minutes_start))
1272+
self.log("Configurating charge window now (now {} target set_window_minutes {} charge start time {}".format(self.time_abs_str(self.minutes_now), self.set_window_minutes, self.time_abs_str(minutes_start)))
12671273
self.adjust_charge_window(charge_start_time, charge_end_time)
12681274
else:
1269-
self.log("Not setting charging window yet as not within the window (now {} target set_window_minutes {} charge start time {}".format(self.minutes_now,self.set_window_minutes, minutes_start))
1275+
self.log("Not setting charging window yet as not within the window (now {} target set_window_minutes {} charge start time {}".format(self.time_abs_str(self.minutes_now),self.set_window_minutes, self.time_abs_str(minutes_start)))
12701276

12711277
# Set configured window minutes for the SOC adjustment routine
12721278
self.charge_start_time_minutes = minutes_start
@@ -1277,7 +1283,7 @@ def update_pred(self):
12771283
if self.minutes_now <= (self.charge_start_time_minutes + 15) and (self.charge_start_time_minutes - self.minutes_now) <= self.set_soc_minutes:
12781284
self.adjust_battery_target(self.charge_limit_percent_best[0])
12791285
else:
1280-
self.log("Not setting charging SOC as we are not within the window (now {} target set_soc_minutes {} charge start time {}".format(self.minutes_now,self.set_soc_minutes, self.charge_start_time_minutes))
1286+
self.log("Not setting charging SOC as we are not within the window (now {} target set_soc_minutes {} charge start time {}".format(self.time_abs_str(self.minutes_now), self.set_soc_minutes, self.time_abs_str(self.charge_start_time_minutes)))
12811287

12821288

12831289
self.log("Completed run")

0 commit comments

Comments
 (0)