From dcda6a1925fad1a57baaaadc3f462b388f0c5c08 Mon Sep 17 00:00:00 2001 From: PK Date: Sat, 24 May 2025 18:56:07 +0200 Subject: [PATCH] api updated:query has changed and now supports list of VINs --- packages/modules/vehicles/polestar/api.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/modules/vehicles/polestar/api.py b/packages/modules/vehicles/polestar/api.py index ec33c72cbc..28708c1b34 100755 --- a/packages/modules/vehicles/polestar/api.py +++ b/packages/modules/vehicles/polestar/api.py @@ -5,6 +5,7 @@ from typing import Optional, Dict from modules.common.component_state import CarState +CAR_TELEMATICS = 'carTelematicsV2' log = logging.getLogger(__name__) @@ -46,15 +47,15 @@ def query_params(self, params: dict, url='https://pc-api.polestar.com/eu-north-1 def get_battery_data(self) -> Optional[Dict]: params = { - "query": "query carTelematics($vin: String!) { carTelematics(vin: $vin) { " + "query": "query " + CAR_TELEMATICS + "($vins: [String!]!) { " + CAR_TELEMATICS + "(vins: $vins) { " + "battery { batteryChargeLevelPercentage estimatedDistanceToEmptyKm } } }", - "operationName": "carTelematics", - "variables": "{\"vin\":\"" + self.vin + "\"}" + "operationName": CAR_TELEMATICS, + "variables": "{\"vins\":\"" + self.vin + "\"}" } result = self.query_params(params) - return result['data']['carTelematics']['battery'] + return result['data'][CAR_TELEMATICS]['battery'][0] def check_vin(self) -> None: # get Vehicle Data