Skip to content

Commit

Permalink
refactor: sleep only when sentry mode off
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Jan 31, 2020
1 parent 8907238 commit 9d0d6fd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions teslajsonpy/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9d0d6fd

Please sign in to comment.