Skip to content

Commit

Permalink
fix: use max of update_interval and SLEEP_INTERVAL
Browse files Browse the repository at this point in the history
This should resolve a situation where a user chooses a bigger
update_interval.
Addresses #HA37340
  • Loading branch information
alandtse committed Jul 3, 2020
1 parent c4954af commit f34df60
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions teslajsonpy/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit f34df60

Please sign in to comment.