From f34df60b3089efa548f385aeff229a9784ea488e Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Thu, 2 Jul 2020 20:53:17 -0700 Subject: [PATCH] fix: use max of update_interval and SLEEP_INTERVAL This should resolve a situation where a user chooses a bigger update_interval. Addresses #HA37340 --- teslajsonpy/controller.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/teslajsonpy/controller.py b/teslajsonpy/controller.py index 91946db6..bd047caf 100644 --- a/teslajsonpy/controller.py +++ b/teslajsonpy/controller.py @@ -584,15 +584,16 @@ def _calculate_next_interval(vin: Text) -> int: ): if self.__update_state[vin] != "trying_to_sleep": self.__update_state[vin] = "trying_to_sleep" + sleep_interval = max(SLEEP_INTERVAL, self.update_interval) _LOGGER.debug( "%s trying to sleep; scan throttled to %s seconds and will ignore updates for %s seconds", vin[-5:], - SLEEP_INTERVAL, + sleep_interval, round( - SLEEP_INTERVAL + self._last_update_time[vin] - cur_time, 2 + sleep_interval + self._last_update_time[vin] - cur_time, 2, ), ) - return SLEEP_INTERVAL + return sleep_interval if self.__update_state[vin] != "normal": self.__update_state[vin] = "normal" _LOGGER.debug(