From 9d0d6fd09032c00160996705dfecb1f471ea1738 Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Thu, 30 Jan 2020 23:17:19 -0800 Subject: [PATCH] refactor: sleep only when sentry mode off --- teslajsonpy/controller.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/teslajsonpy/controller.py b/teslajsonpy/controller.py index 1c48a743..1b7a0e0b 100644 --- a/teslajsonpy/controller.py +++ b/teslajsonpy/controller.py @@ -492,11 +492,15 @@ def _calculate_next_interval(vin: int) -> int: "shift_state" ): self.__last_parked_timestamp[vin] = cur_time - elif (cur_time - (self.__last_parked_timestamp[vin])) > IDLE_INTERVAL: + elif ( + cur_time - (self.__last_parked_timestamp[vin]) + ) > IDLE_INTERVAL and not self.__state[vin].get("sentry_mode"): _LOGGER.debug( "%s trying to sleep; will ignore updates for %s seconds", vin[-5:], - round(SLEEP_INTERVAL + self._last_update_time[vin] - time.time(), 2), + round( + SLEEP_INTERVAL + self._last_update_time[vin] - time.time(), 2 + ), ) return SLEEP_INTERVAL return self.update_interval