Skip to content

Commit

Permalink
fix #29 try-catch on update data
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuen Lee committed Dec 24, 2023
1 parent c56a0f0 commit cd92551
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions custom_components/polestar_api/polestar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

from datetime import timedelta
"""Polestar API for Polestar integration."""
import logging

from .pypolestar.exception import PolestarApiException, PolestarAuthException

from .pypolestar.polestar import PolestarApi

from urllib3 import disable_warnings
Expand Down Expand Up @@ -45,7 +46,12 @@ def get_latest_call_code(self):
return self.polestarApi.latest_call_code

async def async_update(self) -> None:
await self.polestarApi.get_ev_data(self.vin)
try:
await self.polestarApi.get_ev_data(self.vin)
except PolestarApiException as e:
_LOGGER.warning("API Exception on update data %s", str(e))
except PolestarAuthException as e:
_LOGGER.warning("Auth Exception on update data %s", str(e))

def get_value(self, query: str, field_name: str, skip_cache: bool = False):
data = self.polestarApi.get_cache_data(query, field_name, skip_cache)
Expand Down

0 comments on commit cd92551

Please sign in to comment.