Skip to content

Commit

Permalink
log when odometer/battery has been updated
Browse files Browse the repository at this point in the history
  • Loading branch information
jschlyter committed Nov 11, 2024
1 parent 62345dd commit 1f246da
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions custom_components/polestar_api/pypolestar/polestar.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,23 +203,27 @@ async def _get_odometer_data(self, vin: str) -> None:
variable_values={"vin": vin},
)

self.cache_data_by_vin[vin][ODO_METER_DATA] = {
res = self.cache_data_by_vin[vin][ODO_METER_DATA] = {
"data": result[ODO_METER_DATA],
"timestamp": datetime.now(),
}

self.logger.debug("Received odometer data: %s", res)

async def _get_battery_data(self, vin: str) -> None:
result = await self._query_graph_ql(
url=BASE_URL_V2,
query=QUERY_GET_BATTERY_DATA,
variable_values={"vin": vin},
)

self.cache_data_by_vin[vin][BATTERY_DATA] = {
res = self.cache_data_by_vin[vin][BATTERY_DATA] = {
"data": result[BATTERY_DATA],
"timestamp": datetime.now(),
}

self.logger.debug("Received battery data: %s", res)

async def _get_vehicle_data(self, verbose: bool = False) -> dict | None:
"""Get the latest vehicle data from the Polestar API."""
result = await self._query_graph_ql(
Expand Down

0 comments on commit 1f246da

Please sign in to comment.