Skip to content

Commit

Permalink
remove workorder in getcarinfo, fix type locale
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuen Lee committed Jan 19, 2024
1 parent 77ce561 commit c7a4c39
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion custom_components/polestar_api/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async def _create_device(self, username: str, password: str) -> None:
_LOGGER.exception("Unexpected error creating device")
return self.async_abort(reason="api_failed")

return await self._create_entry(username, password, )
return await self._create_entry(username, password)

async def async_step_user(self, user_input: dict = None) -> None:
"""User initiated config flow."""
Expand Down
4 changes: 2 additions & 2 deletions custom_components/polestar_api/pypolestar/polestar.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ async def _get_vehicle_data(self):
"""" Get the latest vehicle data from the Polestar API."""
# get Vehicle Data
params = {
"query": "query GetConsumerCarsV2($locale:String){getConsumerCarsV2(locale:$locale){vin internalVehicleIdentifier salesType currentPlannedDeliveryDate market originalMarket pno34 modelYear belongsToFleet registrationNo metaOrderNumber factoryCompleteDate registrationDate deliveryDate serviceHistory{claimType market mileage mileageUnit operations{id code description quantity performedDate}orderEndDate orderNumber orderStartDate parts{id code description quantity performedDate}status statusDMS symptomCode vehicleAge workshopId}content{exterior{code name description excluded}exteriorDetails{code name description excluded}interior{code name description excluded}performancePackage{code name description excluded}performanceOptimizationSpecification{power{value unit}torqueMax{value unit}acceleration{value unit description}}wheels{code name description excluded}plusPackage{code name description excluded}pilotPackage{code name description excluded}motor{name description excluded}model{name code}images{studio{url angles resolutions}location{url angles resolutions}interior{url angles resolutions}}specification{battery bodyType brakes combustionEngine electricMotors performance suspension tireSizes torque totalHp totalKw trunkCapacity{label value}}dimensions{wheelbase{label value}groundClearanceWithPerformance{label value}groundClearanceWithoutPerformance{label value}dimensions{label value}}towbar{code name description excluded}}primaryDriver primaryDriverRegistrationTimestamp owners{id registeredAt information{polestarId ownerType}}wltpNedcData{wltpCO2Unit wltpElecEnergyConsumption wltpElecEnergyUnit wltpElecRange wltpElecRangeUnit wltpWeightedCombinedCO2 wltpWeightedCombinedFuelConsumption wltpWeightedCombinedFuelConsumptionUnit}energy{elecRange elecRangeUnit elecEnergyConsumption elecEnergyUnit weightedCombinedCO2 weightedCombinedCO2Unit weightedCombinedFuelConsumption weightedCombinedFuelConsumptionUnit}fuelType drivetrain numberOfDoors numberOfSeats motor{description code}maxTrailerWeight{value unit}curbWeight{value unit}hasPerformancePackage numberOfCylinders cylinderVolume cylinderVolumeUnit transmission numberOfGears structureWeek hardware{nodeAddress partNo description{text short}software{partNo}}software{version versionTimestamp performanceOptimization{value description timestamp}}claims{type validFromDate validUntilDate validUntilMileage performedJobs{repairDate}}performedClaims{claimType workshopId market orderNumber claimPerformedManually orderEndDate mileage mileageUnit vehicleAge symptomCode parts{code}operations{code}}latestClaimStatus{mileage mileageUnit registeredDate vehicleAge}internalCar{origin registeredAt}edition commonStatusPoint{code timestamp description}brandStatus{code timestamp description}intermediateDestinationCode partnerDestinationCode features{type code name description excluded galleryImage{url alt}thumbnail{url alt}}electricalEngineNumbers{number placement}}}",
"query": "query GetConsumerCarsV2($locale:String){getConsumerCarsV2(locale:$locale){vin internalVehicleIdentifier salesType currentPlannedDeliveryDate market originalMarket pno34 modelYear belongsToFleet registrationNo metaOrderNumber factoryCompleteDate registrationDate deliveryDate serviceHistory{claimType market mileage mileageUnit operations{id code description quantity performedDate}orderEndDate orderNumber orderStartDate parts{id code description quantity performedDate} statusDMS symptomCode vehicleAge workshopId}content{exterior{code name description excluded}exteriorDetails{code name description excluded}interior{code name description excluded}performancePackage{code name description excluded}performanceOptimizationSpecification{power{value unit}torqueMax{value unit}acceleration{value unit description}}wheels{code name description excluded}plusPackage{code name description excluded}pilotPackage{code name description excluded}motor{name description excluded}model{name code}images{studio{url angles resolutions}location{url angles resolutions}interior{url angles resolutions}}specification{battery bodyType brakes combustionEngine electricMotors performance suspension tireSizes torque totalHp totalKw trunkCapacity{label value}}dimensions{wheelbase{label value}groundClearanceWithPerformance{label value}groundClearanceWithoutPerformance{label value}dimensions{label value}}towbar{code name description excluded}}primaryDriver primaryDriverRegistrationTimestamp owners{id registeredAt information{polestarId ownerType}}wltpNedcData{wltpCO2Unit wltpElecEnergyConsumption wltpElecEnergyUnit wltpElecRange wltpElecRangeUnit wltpWeightedCombinedCO2 wltpWeightedCombinedFuelConsumption wltpWeightedCombinedFuelConsumptionUnit}energy{elecRange elecRangeUnit elecEnergyConsumption elecEnergyUnit weightedCombinedCO2 weightedCombinedCO2Unit weightedCombinedFuelConsumption weightedCombinedFuelConsumptionUnit}fuelType drivetrain numberOfDoors numberOfSeats motor{description code}maxTrailerWeight{value unit}curbWeight{value unit}hasPerformancePackage numberOfCylinders cylinderVolume cylinderVolumeUnit transmission numberOfGears structureWeek hardware{nodeAddress partNo description{text short}software{partNo}}software{version versionTimestamp performanceOptimization{value description timestamp}}claims{type validFromDate validUntilDate validUntilMileage performedJobs{repairDate}}performedClaims{claimType workshopId market orderNumber claimPerformedManually orderEndDate mileage mileageUnit vehicleAge symptomCode parts{code}operations{code}}latestClaimStatus{mileage mileageUnit registeredDate vehicleAge}internalCar{origin registeredAt}edition commonStatusPoint{code timestamp description}brandStatus{code timestamp description}intermediateDestinationCode partnerDestinationCode features{type code name description excluded galleryImage{url alt}thumbnail{url alt}}electricalEngineNumbers{number placement}}}",
"operationName": "GetConsumerCarsV2",
"variables": "{\"local\":\"en_GB\"}"
"variables": "{\"locale\":\"en_GB\"}"
}

result = await self.get_graph_ql(params)
Expand Down
6 changes: 5 additions & 1 deletion custom_components/polestar_api/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
from homeassistant.helpers import entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
from homeassistant.util.unit_conversion import DistanceConverter, EnergyConverter, SpeedConverter
from homeassistant.util.unit_conversion import (
DistanceConverter,
EnergyConverter,
SpeedConverter,
)

from . import DOMAIN as POLESTAR_API_DOMAIN
from .entity import PolestarEntity
Expand Down

0 comments on commit c7a4c39

Please sign in to comment.