Skip to content

Commit

Permalink
fix #72, #74: fix odo meter max limit, use Unit_of_measurement on km/…
Browse files Browse the repository at this point in the history
…miles/meter, fix refresh token on too long expired token
  • Loading branch information
Tuen Lee committed Jan 8, 2024
1 parent 71601cd commit 78c2464
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 123 deletions.
1 change: 1 addition & 0 deletions custom_components/polestar_api/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ def __init__(self, device: Polestar) -> None:
async def async_added_to_hass(self) -> None:
"""Add listener for state changes."""
await super().async_added_to_hass()

3 changes: 2 additions & 1 deletion custom_components/polestar_api/pypolestar/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ async def get_token(self, refresh=False) -> None:
"""Get the token from Polestar."""
headers = {"Content-Type": "application/json"}
operationName = "getAuthToken"
if not refresh:
# can't use refresh if the token is expired or not set even if refresh is True
if not refresh or self.token_expiry is None or self.token_expiry < datetime.now():
code = await self._get_code()
if code is None:
return
Expand Down
Loading

0 comments on commit 78c2464

Please sign in to comment.