Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/modules/vehicles/polestar/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Optional, Dict
from modules.common.component_state import CarState

CAR_TELEMATICS = 'carTelematicsV2'

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -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
Expand Down