Skip to content

Commit 8a61522

Browse files
committed
Fix logic in inverter charge controller pause timing
Correct the logic in `inverter_charge_controller.py` by properly setting the pause time to `next_price_minimum` instead of `time_to_sleep_to`.
1 parent 86c769b commit 8a61522

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

source/inverter_charge_controller.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ def start(self) -> None:
5555
else:
5656
next_price_minimum, minimum_has_to_be_rechecked = self._do_iteration()
5757

58-
time_to_sleep_to = next_price_minimum
5958
if minimum_has_to_be_rechecked:
6059
time_to_sleep_to = datetime.now(tz=self.timezone).replace(
6160
hour=14, minute=0, second=0, microsecond=0
6261
)
6362
self.log.info(f"The price minimum has to re-checked at {time_to_sleep_to}. Waiting until then...")
6463
pause.until(time_to_sleep_to)
64+
self.log.info("Waking up since the the price minimum has to re-checked")
6565
next_price_minimum, _ = self.tibber_api_handler.get_timestamp_of_next_price_minimum(True)
6666

6767
self.log.info(f"The next price minimum is at {next_price_minimum}. Waiting until then...")
6868

6969
self._write_newlines_to_log_file()
70-
pause.until(time_to_sleep_to)
70+
pause.until(next_price_minimum)
7171

7272
except (ClientError, RequestException) as e:
7373
self.log.exception(f"An exception occurred while trying to fetch data from a different system: {e}")

source/sun_forecast_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def get_solar_output_in_timeframe(self, timestamp_start: datetime, timestamp_end
9090
The estimated amount of energy generated from solar output within the specified timeframe.
9191
9292
"""
93-
self.log.debug(f"Getting estimated solar output between {timestamp_start} and {timestamp_end}")
93+
self.log.debug(f"Calculating estimated solar output between {timestamp_start} and {timestamp_end}")
9494

9595
sunrise_plus_offset, sunset_minus_offset = self._get_sunset_and_sunrise_with_offset()
9696
daylight_duration_in_seconds = (sunset_minus_offset - sunrise_plus_offset).total_seconds()

0 commit comments

Comments
 (0)