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
10 changes: 5 additions & 5 deletions packages/modules/vehicles/polestar/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ def query_params(self, params: dict, url='https://pc-api.polestar.com/eu-north-1

def get_battery_data(self) -> dict or None:
params = {
"query": "query GetBatteryData($vin: String!) { getBatteryData(vin: $vin) { "
+ "batteryChargeLevelPercentage estimatedDistanceToEmptyKm } }",
"operationName": "GetBatteryData",
"query": "query carTelematics($vin: String!) { carTelematics(vin: $vin) { "
+ "battery { batteryChargeLevelPercentage estimatedDistanceToEmptyKm } } }",
"operationName": "carTelematics",
"variables": "{\"vin\":\"" + self.vin + "\"}"
}

result = self.query_params(params)

return result['data']['getBatteryData']
return result['data']['carTelematics']['battery']

def check_vin(self) -> None:
# get Vehicle Data
Expand All @@ -62,7 +62,7 @@ def check_vin(self) -> None:
"operationName": "GetConsumerCarsV2",
"variables": "{}"
}
result = self.query_params(params, url='https://pc-api.polestar.com/eu-north-1/my-star/')
result = self.query_params(params)
if result is not None and result['data'] is not None:
vins = []
# get list of cars and store the ones not matching our vin
Expand Down