Skip to content

Commit

Permalink
fix(USA Hyundai): Time Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cdnninja committed Jan 21, 2022
1 parent 0cbc45b commit 31787eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions hyundai_kia_connect_api/HyundaiBlueLinkAPIUSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def proxy_manager_for(self, *args, **kwargs):
class HyundaiBlueLinkAPIUSA(ApiImpl):

# initialize with a timestamp which will allow the first fetch to occur
last_loc_timestamp = dt.now() - dt.timedelta(hours=3)
last_loc_timestamp = dt.datetime.now(pytz.utc) - dt.timedelta(hours=3)

def __init__(
self,
Expand Down Expand Up @@ -294,7 +294,7 @@ def get_location(self, token: Token, vehicle: Vehicle) -> None:
#headers["pAuth"] = self.get_pin_token(token)

try:
HyundaiBlueLinkAPIUSA.last_loc_timestamp = dt.now()
HyundaiBlueLinkAPIUSA.last_loc_timestamp = dt.datetime.now(pytz.utc)
response = self.sessions.get(url, headers=headers)
response_json = response.json()
_LOGGER.debug(f"{DOMAIN} - Get Vehicle Location {response_json}")
Expand All @@ -310,7 +310,7 @@ def get_location(self, token: Token, vehicle: Vehicle) -> None:
):
# rate limit exceeded; set the last_loc_timestamp such that the next check will be at least 12 hours from now
HyundaiBlueLinkAPIUSA.last_loc_timestamp = (
dt.now() + dt.timedelta(hours=11)
dt.datetime.now(pytz.utc) + dt.timedelta(hours=11)
)
_LOGGER.warn(
f"{DOMAIN} - get vehicle location rate limit exceeded. Location will not be fetched until at least {HyundaiBlueLinkAPIUSA.last_loc_timestamp + dt.timedelta(hours = 12)}"
Expand Down

0 comments on commit 31787eb

Please sign in to comment.