Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APIs changed? #46

Open
augmentedtraffic opened this issue Jun 11, 2024 · 77 comments
Open

APIs changed? #46

augmentedtraffic opened this issue Jun 11, 2024 · 77 comments
Labels
breaking Breaking Changes

Comments

@augmentedtraffic
Copy link

On the web site there was a notice about upcoming changes and now when I issue a request I still get data but no useful values
vehicles = await client.getVehicles()
for vehicle in vehicles:
print(json.dumps(vehicle, indent=2))
vins = map(lambda v: v["vin"], vehicles)
for vin in vins:
data = await client.getCurrentOverview(vin)
print(json.dumps(data, indent=2))

Just wondering if anyone else is seeing this?

VIN: xxxxModel: None Year: None
datat is {'vin': 'xxx', 'oilLevel': None, 'fuelLevel': None, 'batteryLevel': None, 'remainingRanges': {'conventionalRange': None, 'electricalRange': None}, 'mileage': None, 'parkingLight': 'INVALID', 'parkingLightStatus': None, 'parkingBreak': 'INVALID', 'parkingBreakStatus': None, 'doors': {'frontLeft': 'INVALID', 'frontRight': 'INVALID', 'backLeft': 'INVALID', 'backRight': 'INVALID', 'frontTrunk': 'INVALID', 'backTrunk': 'INVALID', 'overallLockStatus': 'CLOSED_LOCKED'}, 'serviceIntervals': {'oilService': None, 'inspection': None}, 'tires': {'frontLeft': {'currentPressure': None, 'optimalPressure': None, 'differencePressure': None, 'tirePressureDifferenceStatus': 'UNKNOWN'}, 'frontRight': {'currentPressure': None, 'optimalPressure': None, 'differencePressure': None, 'tirePressureDifferenceStatus': 'UNKNOWN'}, 'backLeft': {'currentPressure': None, 'optimalPressure': None, 'differencePressure': None, 'tirePressureDifferenceStatus': 'UNKNOWN'}, 'backRight': {'currentPressure': None, 'optimalPressure': None, 'differencePressure': None, 'tirePressureDifferenceStatus': 'UNKNOWN'}}, 'windows': {'frontLeft': 'INVALID', 'frontRight': 'INVALID', 'backLeft': 'INVALID', 'backRight': 'INVALID', 'roof': 'INVALID', 'maintenanceHatch': 'INVALID', 'sunroof': {'status': 'INVALID', 'positionInPercent': None}}, 'parkingTime': None, 'overallOpenStatus': 'CLOSED', 'chargingStatus': None, 'carModel': None, 'engineType': None, 'chargingState': None}

IN: WP0CD2A9XRS257470 Model: None Year: None
{
"vin": "xxx",
"oilLevel": null,
"fuelLevel": null,
"batteryLevel": null,
"remainingRanges": {
"conventionalRange": null,
"electricalRange": null
},
"mileage": null,
"parkingLight": "INVALID",
"parkingLightStatus": null,
"parkingBreak": "INVALID",
"parkingBreakStatus": null,
"doors": {
"frontLeft": "INVALID",
"frontRight": "INVALID",
"backLeft": "INVALID",
"backRight": "INVALID",
"frontTrunk": "INVALID",
"backTrunk": "INVALID",
"overallLockStatus": "CLOSED_LOCKED"
},
"serviceIntervals": {
"oilService": null,
"inspection": null
},
"tires": {
"frontLeft": {
"currentPressure": null,
"optimalPressure": null,
"differencePressure": null,
"tirePressureDifferenceStatus": "UNKNOWN"
},
"frontRight": {
"currentPressure": null,
"optimalPressure": null,
"differencePressure": null,
"tirePressureDifferenceStatus": "UNKNOWN"
},
"backLeft": {
"currentPressure": null,
"optimalPressure": null,
"differencePressure": null,
"tirePressureDifferenceStatus": "UNKNOWN"
},
"backRight": {
"currentPressure": null,
"optimalPressure": null,
"differencePressure": null,
"tirePressureDifferenceStatus": "UNKNOWN"
}
},
"windows": {
"frontLeft": "INVALID",
"frontRight": "INVALID",
"backLeft": "INVALID",
"backRight": "INVALID",
"roof": "INVALID",
"maintenanceHatch": "INVALID",
"sunroof": {
"status": "INVALID",
"positionInPercent": null
}
},
"parkingTime": null,
"overallOpenStatus": "CLOSED",
"chargingStatus": null,
"carModel": null,
"engineType": null,
"chargingState": null
}

thanks

@fredriklj
Copy link
Collaborator

Indeed, the APIs we used to rely on are retired. So the current version if this library is completely defunct. I've had a first stab at the new APIs in this branch:

https://github.com/CJNE/pyporscheconnectapi/tree/new_api

It currently only supports authentication and retrieving capabilities and status.

@augmentedtraffic
Copy link
Author

OK I can get some valid data - looks like some changes in the JSON but will explore and see what I can for my use cases - thanks and I will let you know if it works

@fredriklj fredriklj added the breaking Breaking Changes label Jun 18, 2024
@fredriklj
Copy link
Collaborator

Can someone with am ICE-based drivetrain please post the output data from the 'overview' command (vin, location etc. redacted) using new_api branch? Would be most helpful, as I only have access to data from an EV.

@augmentedtraffic
Copy link
Author

two ICEs - some parts redacted hope this helps - I think some things are slightly different even between the two cars.

{
"vin": "editted",
"modelName": "Panamera editted",
"customName": "",
"modelType": {
"code": "97AFR1",
"year": "2023",
"body": "SEDAN",
"generation": "G2",
"model": "PANAMERA",
"engine": "COMBUSTION"
},
"systemInfo": {
"driverExperience": "0.5",
"privacyStyle": 1
},
"exteriorColorName": "Volcano Grey Metallic/Volcano Grey Metallic",
"color": {
"primaryExteriorColor": "252625"
},
"connect": true,
"greyConnectStoreURL": "https://connect-store.porsche.com",
"timestamp": "2024-06-19T23:15:01Z",
"commands": [],
"measurements": [
{
"key": "OPEN_STATE_TOP",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "CHARGING_PROFILES",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "E_RANGE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "OPEN_STATE_SERVICE_FLAP",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "BATTERY_CHARGING_STATE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "CHARGING_SUMMARY",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "BATTERY_LEVEL",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "OPEN_STATE_CHARGE_FLAP_LEFT",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "OPEN_STATE_SPOILER",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "OPEN_STATE_CHARGE_FLAP_RIGHT",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "DEPARTURES",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "REMOTE_ACCESS_AUTHORIZATION",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:01Z",
"isEnabled": true
}
},
{
"key": "GLOBAL_PRIVACY_MODE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:01Z",
"isEnabled": false
}
},
{
"key": "CLIMATIZER_STATE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "TIMERS",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "HEATING_STATE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "BLEID_DDADATA",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "ACV_STATE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "FUEL_RESERVE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:01Z",
"percent": 15
}
},
{
"key": "THEFT_STATE",
"status": {
"isEnabled": false,
"cause": "LICENSE_DEACTIVATED"
}
},
{
"key": "ALARM_STATE",
"status": {
"isEnabled": false,
"cause": "LICENSE_DEACTIVATED"
}
},
{
"key": "VTS_MODES",
"status": {
"isEnabled": false,
"cause": "LICENSE_DEACTIVATED"
}
},
{
"key": "GPS_LOCATION",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-18T22:27:17Z",
"location": "editted",
"direction": 341
}
},
{
"key": "PAIRING_CODE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "MILEAGE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"kilometers": 12130
}
},
{
"key": "OIL_SERVICE_RANGE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-18T18:26:07Z",
"kilometers": 7400
}
},
{
"key": "OIL_SERVICE_TIME",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-18T18:26:07Z",
"days": 137
}
},
{
"key": "MAIN_SERVICE_RANGE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-18T18:26:07Z",
"kilometers": 17900
}
},
{
"key": "MAIN_SERVICE_TIME",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-18T18:26:07Z",
"days": 117
}
},
{
"key": "PARKING_BRAKE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"isOn": false
}
},
{
"key": "RANGE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"kilometers": 371
}
},
{
"key": "FUEL_LEVEL",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"percent": 61
}
},
{
"key": "OPEN_STATE_DOOR_FRONT_LEFT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_DOOR_REAR_LEFT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_DOOR_FRONT_RIGHT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_DOOR_REAR_RIGHT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_LID_REAR",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_LID_FRONT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_WINDOW_FRONT_LEFT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_WINDOW_REAR_LEFT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_WINDOW_FRONT_RIGHT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_WINDOW_REAR_RIGHT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_SUNROOF",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"isOpen": false
}
},
{
"key": "OIL_LEVEL_CURRENT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-18T22:26:07Z",
"percent": 25
}
},
{
"key": "OIL_LEVEL_MAX",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-18T18:26:07Z",
"liters": 2.0
}
},
{
"key": "OIL_LEVEL_MIN_WARNING",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-18T18:26:07Z",
"isEnabled": false
}
},
{
"key": "LOCK_STATE_VEHICLE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:22Z",
"isLocked": true
}
},
{
"key": "PARKING_LIGHT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:30Z",
"isOn": false
}
},
{
"key": "SERVICE_PREDICTIONS",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "PRED_PRECON_LOCATION_EXCEPTIONS",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "PRED_PRECON_USER_SETTINGS",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "INTERMEDIATE_SERVICE_TIME",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "INTERMEDIATE_SERVICE_RANGE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
}
]
}

{
"vin": "editted",
"modelName": "911 editted",
"customName": "",
"modelType": {
"code": "992650",
"year": "2024",
"body": "CABRIO",
"generation": "992",
"model": "911",
"engine": "COMBUSTION"
},
"systemInfo": {
"driverExperience": "0.5",
"privacyStyle": 1
},
"exteriorColorName": "Jet Black Metallic/Cabriolet Roof in Black",
"color": {
"primaryExteriorColor": "000000"
},
"connect": true,
"greyConnectStoreURL": "https://connect-store.porsche.com",
"timestamp": "2024-06-19T23:15:23Z",
"commands": [],
"measurements": [
{
"key": "OPEN_STATE_LID_REAR",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "OPEN_STATE_DOOR_REAR_RIGHT",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "CHARGING_PROFILES",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "E_RANGE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "BATTERY_CHARGING_STATE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "CHARGING_SUMMARY",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "BATTERY_LEVEL",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "OPEN_STATE_CHARGE_FLAP_LEFT",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "OPEN_STATE_SPOILER",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "OPEN_STATE_DOOR_REAR_LEFT",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "OPEN_STATE_CHARGE_FLAP_RIGHT",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "DEPARTURES",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "OPEN_STATE_SUNROOF",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "REMOTE_ACCESS_AUTHORIZATION",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:23Z",
"isEnabled": true
}
},
{
"key": "GLOBAL_PRIVACY_MODE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:23Z",
"isEnabled": false
}
},
{
"key": "CLIMATIZER_STATE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "TIMERS",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "HEATING_STATE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "BLEID_DDADATA",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "ACV_STATE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "FUEL_RESERVE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:23Z",
"percent": 15
}
},
{
"key": "THEFT_STATE",
"status": {
"isEnabled": false,
"cause": "LICENSE_DEACTIVATED"
}
},
{
"key": "ALARM_STATE",
"status": {
"isEnabled": false,
"cause": "LICENSE_DEACTIVATED"
}
},
{
"key": "VTS_MODES",
"status": {
"isEnabled": false,
"cause": "LICENSE_DEACTIVATED"
}
},
{
"key": "GPS_LOCATION",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T20:59:27Z",
"location": "editted",
"direction": 165
}
},
{
"key": "PAIRING_CODE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "MILEAGE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"kilometers": 2673
}
},
{
"key": "OIL_SERVICE_RANGE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T16:58:27Z",
"kilometers": 12400
}
},
{
"key": "OIL_SERVICE_TIME",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T16:58:27Z",
"days": 198
}
},
{
"key": "MAIN_SERVICE_RANGE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T16:58:27Z",
"kilometers": 27400
}
},
{
"key": "MAIN_SERVICE_TIME",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T16:58:27Z",
"days": 563
}
},
{
"key": "PARKING_BRAKE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"isOn": true
}
},
{
"key": "RANGE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"kilometers": 473
}
},
{
"key": "FUEL_LEVEL",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"percent": 93
}
},
{
"key": "OPEN_STATE_DOOR_FRONT_LEFT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_DOOR_FRONT_RIGHT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_LID_FRONT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_WINDOW_FRONT_LEFT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_WINDOW_REAR_LEFT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_WINDOW_FRONT_RIGHT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_WINDOW_REAR_RIGHT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_TOP",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"isOpen": false
}
},
{
"key": "OPEN_STATE_SERVICE_FLAP",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"isOpen": false
}
},
{
"key": "OIL_LEVEL_CURRENT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-18T15:25:05Z",
"percent": 100
}
},
{
"key": "OIL_LEVEL_MAX",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-18T15:25:05Z",
"liters": 1.0
}
},
{
"key": "OIL_LEVEL_MIN_WARNING",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-18T15:25:05Z",
"isEnabled": false
}
},
{
"key": "LOCK_STATE_VEHICLE",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"isLocked": true
}
},
{
"key": "PARKING_LIGHT",
"status": {
"isEnabled": true
},
"value": {
"lastModified": "2024-06-19T23:15:45Z",
"isOn": false
}
},
{
"key": "SERVICE_PREDICTIONS",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "PRED_PRECON_LOCATION_EXCEPTIONS",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "PRED_PRECON_USER_SETTINGS",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "INTERMEDIATE_SERVICE_TIME",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
},
{
"key": "INTERMEDIATE_SERVICE_RANGE",
"status": {
"isEnabled": false,
"cause": "NOT_SUPPORTED"
}
}
]
}

@CTRDevelopments
Copy link

Hopefully you can help. How do i install this updated version?

Do I need the original HACS integration and then install this over the top? Or do I just install this (then how do I access the date in HA?)

sorry for being a bit simple

cheers

@fredriklj
Copy link
Collaborator

Thanks @augmentedtraffic . Helps a lot to know the units and attributes for oil, fuel, etc.

@CTRDevelopments, if you want to test it out, check out the new_api branch and install using pip. But for know I got what is needed. No need to go through the hass integration at this point.

@moballa
Copy link

moballa commented Jun 20, 2024

@fredriklj - I'm unable to get your new_api branch working. I tried example2.py and am getting the following "401 Unathorized" on the vehicles endpoint

DEBUG:pyporscheconnectapi.connection:TraceRequestEndParams(method='GET', url=URL('https://api.ppa.porsche.com/app/connect/v1/vehicles/WPXXXXXXXXXX'), headers=<CIMultiDict()>, response=<ClientResponse(https://api.ppa.porsche.com/app/connect/v1/vehicles/WPXXXXXXXXXXX?mf=BATTERY_LEVEL&mf=LOCK_STATE_VEHICLE) [401 Unauthorized]>

It seems to be logging in because it is able to retrieve the VIN associated with my account.

The pip install pyporscheconnectapi is installing 0.1.7 from November 2023 ... is this correct??

@moballa
Copy link

moballa commented Jun 20, 2024

Nevermind, I overrode the python library package with the version in the new_api branch. All good. Works again, thanks!

@CTRDevelopments
Copy link

Thanks @augmentedtraffic . Helps a lot to know the units and attributes for oil, fuel, etc.

@CTRDevelopments, if you want to test it out, check out the new_api branch and install using pip. But for know I got what is needed. No need to go through the hass integration at this point.

@fredriklj , super. I have installed via PIP but how do i get the data? Sorry if this seems like a noobie type question. Cheers

@augmentedtraffic
Copy link
Author

if a new install this should work

pip3 install git+https://github.com/CJNE/pyporscheconnectapi.git@new_api

(or just pip ... if you only have python 3 installed)

@CTRDevelopments
Copy link

@augmentedtraffic - thanks.

I then got the message below. Should this now appear in the integrations page on Home Assistant? Cheers

➜ ~ pip3 install git+https://github.com/CJNE/pyporscheconnectapi.git@new_api
Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/
Collecting git+https://github.com/CJNE/pyporscheconnectapi.git@new_api
Cloning https://github.com/CJNE/pyporscheconnectapi.git (to revision new_api) to /tmp/pip-req-build-2puhbg35
Running command git clone --filter=blob:none --quiet https://github.com/CJNE/pyporscheconnectapi.git /tmp/pip-req-build-2puhbg35
Running command git checkout -b new_api --track origin/new_api
branch 'new_api' set up to track 'origin/new_api'.
Switched to a new branch 'new_api'
Resolved https://github.com/CJNE/pyporscheconnectapi.git to commit e3d6bd2
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: aiohttp<4 in /usr/lib/python3.12/site-packages (from pyporscheconnectapi==0.2.0) (3.9.5)
Requirement already satisfied: aiosignal>=1.1.2 in /usr/lib/python3.12/site-packages (from aiohttp<4->pyporscheconnectapi==0.2.0) (1.3.1)
Requirement already satisfied: attrs>=17.3.0 in /usr/lib/python3.12/site-packages (from aiohttp<4->pyporscheconnectapi==0.2.0) (23.2.0)
Requirement already satisfied: frozenlist>=1.1.1 in /usr/lib/python3.12/site-packages (from aiohttp<4->pyporscheconnectapi==0.2.0) (1.4.1)
Requirement already satisfied: multidict<7.0,>=4.5 in /usr/lib/python3.12/site-packages (from aiohttp<4->pyporscheconnectapi==0.2.0) (6.0.5)
Requirement already satisfied: yarl<2.0,>=1.0 in /usr/lib/python3.12/site-packages (from aiohttp<4->pyporscheconnectapi==0.2.0) (1.9.4)
Requirement already satisfied: idna>=2.0 in /usr/lib/python3.12/site-packages (from yarl<2.0,>=1.0->aiohttp<4->pyporscheconnectapi==0.2.0) (3.7)
Building wheels for collected packages: pyporscheconnectapi
Building wheel for pyporscheconnectapi (pyproject.toml) ... done
Created wheel for pyporscheconnectapi: filename=pyporscheconnectapi-0.2.0-py3-none-any.whl size=10317 sha256=6db70634844efc29b3543b79f408b23f38576bc1e7ad910d98174a5404612c56
Stored in directory: /tmp/pip-ephem-wheel-cache-zkzipvsw/wheels/47/0d/4b/31eaf25a388cd6bdb42f73be9b38019628c96cf6a441c20b54
Successfully built pyporscheconnectapi
Installing collected packages: pyporscheconnectapi
Attempting uninstall: pyporscheconnectapi
Found existing installation: pyporscheconnectapi 0.1.7
Uninstalling pyporscheconnectapi-0.1.7:
Successfully uninstalled pyporscheconnectapi-0.1.7
Successfully installed pyporscheconnectapi-0.2.0

@fredriklj
Copy link
Collaborator

@CTRDevelopments No, you would need to clone the "new_api" branch from the ha-porscheconnect repo into custom_components of your config directory for hass as well, to override the current (non-functional) version of the integration from HACS.

But beware, it is in very early stage of development and currently only have a few read-only entities. It will take some time before we (hopefully) can have a functional integration again.

@CTRDevelopments
Copy link

@fredriklj Thanks for the info. I have now installed the original integration,

then run - pip3 install git+https://github.com/CJNE/pyporscheconnectapi.git@new_api

Then copied the files from the github sub folder - pyporscheconnectapi to home assistant (init.py, cli.py, client.py, connection.py, const.py exceptions.py) - do i need any others? I replaced all original files with the new ones

It is now giving me an error 'config flow could not be loaded, unknown error'

not sure what I have missed.

Cheers

@fredriklj
Copy link
Collaborator

The repo you need to clone into custom_components is here:

https://github.com/CJNE/ha-porscheconnect

@CTRDevelopments
Copy link

The repo you need to clone into custom_components is here:

https://github.com/CJNE/ha-porscheconnect

ahh so the original repo. Does installing this from HACS do this automatically?

I am manually downloading files to my PC and then uploading through 'studio code viewer' in Home Assistant. Should this work?

cheers

@normanmaurer
Copy link

@fredriklj just wanted to say that this works great at least for the "read-only" things together with ha-porscheconnect. Now I can again have the charge level of my taycan on my watch. Thanks a lot!

@fredriklj
Copy link
Collaborator

@normanmaurer Thanks for letting me know. There are some issues with getting response code 429 (too many requests) after a while. I'm looking into that issue.

@normanmaurer
Copy link

@fredriklj thanks a lot! Maybe you could also help out the evcc project by providing some the traffic data that you used to reengineer the API: evcc-io/evcc#14371 (comment)

@wisq
Copy link

wisq commented Jul 4, 2024

Yeah, I too am definitely interested in figuring out the new API — I wrote https://github.com/wisq/porsche_conn_ex (largely based on this library), and https://github.com/wisq/tay_calendar to sync my Google Calendar events to car timers, and of course a few months later, they discontinue the API and break everything. 🤦

I've not got much experience reverse engineering APIs or MitMing apps, so I was sorta waiting to see what happened with this project, but I can give it a go myself when I get a bit of spare time. Glad to see we're back to at least basic authentication and read-only access, though! 🎉

@fredriklj
Copy link
Collaborator

I need to work out the basics first, and as I think I wrote, I have quite limited time to spend on this currently. Will try to do whatever I can, but any help would be much appreciated.

@CTRDevelopments
Copy link

Hi, I am still very keen, but unfortunately I cannot get this working, although I suspect this is me rather than any error! Is it possible to describe the install steps again? I thought I understood, but I guess not :) Cheers

@normanmaurer
Copy link

@CTRDevelopments this is what worked for me:

pip3 install git+https://github.com/CJNE/pyporscheconnectapi.git@new_api
git clone https://github.com/CJNE/ha-porscheconnect.git
cd ha-porscheconnect
git checkout new_api
cp -r custom_components/porscheconnect homeassistant_directory/custom_components

Restart homeassistant

@fredriklj
Copy link
Collaborator

In case anyone has any good ideas, this is where I am currently stuck:

  1. It seems one can keep refreshing the tokens for about three hours. After this time window has elapsed, you'll get a 429 (Too many requests) error.
  2. The query rate does not seem to matter, changing the polling interval from 15 to 30 minutes still gives you a three hour window. Also, it doesn't matter if you are getting the stored or request current overview.
  3. There is no Retry-After header, which could have indicated for how long the server wants you back-off. Which leads me to believe there is something else bothering the server side.

Closing the session entirely and starting all over will give you a new three-hour window, but that does not seem to be the proper way to do it. As we are trying our best to be nice and polite to the API.

I just saw that we didn't set the User-Agent header properly, but that's a long-shot. Ideas welcome.

@normanmaurer
Copy link

I can confirm that there are no issues after I changed the polling to 35min interval

@marklane-develop
Copy link

The new_api branch has been working nicely for me (2016 Cayenne S E-Hybrid). I've been polling at 5 minutes for about 5 hours today without issue but have backed off to 32 minutes so as not to trip the 429 threshold.

@Jimnaldo
Copy link

Jimnaldo commented Oct 5, 2024

@fredriklj any idea why this error occurs in HA: config flow could not be loaded: 500 Internal server error server got itself in trouble?

@marklane-develop
Copy link

Spoke too soon - left it running on a 32 minute polling interval and some time overnight got hit with the 429 Too Many Requests

@wingrunr21
Copy link

@fredriklj (or anyone else), have you tried a backoff function when you see the 429? I'm wondering if they are tagging you once you hit that threshold and you need to refresh the whole token to reset it or if slowing it down for a tad will re-enable the API.

@marklane-develop
Copy link

marklane-develop commented Oct 10, 2024

@wingrunr21 I haven't tried that yet but it's a good thought. My test rig setup is a simple Python app just creating a new connection, client and call on every invocation of my schedule (i.e. not inside HA). I'm guessing this would create an entire new session and initial token every time?

e.g.

conn = Connection(USERNAME, PASSWORD)
client = Client(conn)
data = await client.getStoredOverview(VIN)
…process data…
await conn.close()

I moved to getStoredOverview() from getCurrentOverview() and it now seems to be fine on a 32 minute polling interview (no more 429) but I guess without the "wakeup" call it's not requesting data from the car as often (it does however show some updates form the car at various times - range, SoC, fuel etc...) - perhaps this is happening when the car "phones home" based upon certain events? (e.g. lock/unlock, charge start/stop etc...)?

@fredriklj
Copy link
Collaborator

@wingrunr21 @marklane-develop Right, I believe you should rely on the stored overview for regular polling and only call for current overview on-demand. It looks to me like the car update the backend with data on some regular intervals regardless, so just polling the stored overview avoids waking up the car and also gives much faster response times.

@MarkusGH
Copy link

MarkusGH commented Nov 1, 2024

I installed with pip3 install git+https://github.com/CJNE/pyporscheconnectapi.git@new_api

porschecli overview -v "WP1ZZZXXX"

Traceback (most recent call last):
  File "/usr/local/bin/porschecli", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/cli.py", line 157, in cli
    loop.run_until_complete(main(args))
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/cli.py", line 64, in main
    data = await client.getCurrentOverview(vin)
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/client.py", line 55, in getCurrentOverview
    data = await self._connection.get(
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/connection.py", line 336, in get
    headers = await self._createhead()
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/connection.py", line 378, in _createhead
    if token["expiration"] < now:
KeyError: 'expiration'
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7fe16b8ebb20>

Am I doing something wrong here?

@wingrunr21
Copy link

You should re-pull and retry. That key error occurred because the CLI would pass an empty dict into the client when there was no saved token but the connection code didn't handle that before trying to access that key. It should be addressed with #49 now merged

@MarkusGH
Copy link

MarkusGH commented Nov 1, 2024

pip3 uninstall pyporscheconnectapi did the trick.

Called porschecli overview -v "WP1ZZZXXX" multiple times, because I could not read battery level and other values:

    {
      "key": "BATTERY_LEVEL",
      "status": {
        "isEnabled": false,
        "cause": "UNKNOWN",
        "code": "25A09"
      }
    },

After some calls I get:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/connection.py", line 100, in request
    resp.raise_for_status()
  File "/usr/local/lib/python3.8/dist-packages/httpx/_models.py", line 763, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://api.ppa.porsche.com/app/connect/v1/vehicles/WP1ZZZXXX?mf=ACV_STATE&mf=ALARM_STATE&mf=BATTERY_CHARGING_STATE&mf=BATTERY_LEVEL&mf=BLEID_DDADATA&mf=CHARGING_PROFILES&mf=CHARGING_SUMMARY&mf=CLIMATIZER_STATE&mf=DEPARTURES&mf=E_RANGE&mf=FUEL_LEVEL&mf=FUEL_RESERVE&mf=GLOBAL_PRIVACY_MODE&mf=GPS_LOCATION&mf=HEATING_STATE&mf=INTERMEDIATE_SERVICE_RANGE&mf=INTERMEDIATE_SERVICE_TIME&mf=LOCK_STATE_VEHICLE&mf=MAIN_SERVICE_RANGE&mf=MAIN_SERVICE_TIME&mf=MILEAGE&mf=OIL_LEVEL_CURRENT&mf=OIL_LEVEL_MAX&mf=OIL_LEVEL_MIN_WARNING&mf=OIL_SERVICE_RANGE&mf=OIL_SERVICE_TIME&mf=OPEN_STATE_CHARGE_FLAP_LEFT&mf=OPEN_STATE_CHARGE_FLAP_RIGHT&mf=OPEN_STATE_DOOR_FRONT_LEFT&mf=OPEN_STATE_DOOR_FRONT_RIGHT&mf=OPEN_STATE_DOOR_REAR_LEFT&mf=OPEN_STATE_DOOR_REAR_RIGHT&mf=OPEN_STATE_LID_FRONT&mf=OPEN_STATE_LID_REAR&mf=OPEN_STATE_SERVICE_FLAP&mf=OPEN_STATE_SPOILER&mf=OPEN_STATE_SUNROOF&mf=OPEN_STATE_TOP&mf=OPEN_STATE_WINDOW_FRONT_LEFT&mf=OPEN_STATE_WINDOW_FRONT_RIGHT&mf=OPEN_STATE_WINDOW_REAR_LEFT&mf=OPEN_STATE_WINDOW_REAR_RIGHT&mf=PAIRING_CODE&mf=PARKING_BRAKE&mf=PARKING_LIGHT&mf=PRED_PRECON_LOCATION_EXCEPTIONS&mf=PRED_PRECON_USER_SETTINGS&mf=RANGE&mf=REMOTE_ACCESS_AUTHORIZATION&mf=SERVICE_PREDICTIONS&mf=THEFT_STATE&mf=TIMERS&mf=VTS_MODES&wakeUpJob=7113f746-52e9-43b0-b80c-c0f6d1f9e2cb'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/porschecli", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/cli.py", line 157, in cli
    loop.run_until_complete(main(args))
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/cli.py", line 64, in main
    data = await client.getCurrentOverview(vin)
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/client.py", line 53, in getCurrentOverview
    data = await self._connection.get(
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/connection.py", line 79, in get
    return await self.request("GET", url, params=params)
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/connection.py", line 103, in request
    raise PorscheException(exception_.response.status_code)
pyporscheconnectapi.exceptions.PorscheException

Did I hit a rate limit or is there another issue?

@fredriklj
Copy link
Collaborator

It doesn't look like the rate limit, but can't tell from the output above what is going wrong. Would be interesting to know if you are able to investigate it?

@MarkusGH
Copy link

MarkusGH commented Nov 1, 2024

It works again - no idea.

@wingrunr21
Copy link

you could turn on debug logging via the CLI option. there's pretty extensive logging through the library

@MarkusGH
Copy link

MarkusGH commented Nov 2, 2024

OK - error 400 raised its ugly head again:

porschecli -d overview -v "WP1ZZZXXX"

DEBUG:httpx:load_ssl_context verify=False cert=None trust_env=True http2=False
DEBUG:pyporscheconnectapi.connection:Request headers: Headers({'host': 'api.ppa.porsche.com', 'accept': '*/*', 'accept-encoding': 'gzip, deflate, br', 'connection': 'keep-alive', 'user-agent': 'pyporscheconnectapi/0.2.0', 'x-client-id': 'XhygisuebbrqQ80byOuU5VncxLIm8E6H', 'authorization': '[secure]'})
DEBUG:pyporscheconnectapi.connection:Request method - url: GET https://api.ppa.porsche.com/app/connect/v1/vehicles/WP1ZZZXXX?mf=ACV_STATE&mf=ALARM_STATE&mf=BATTERY_CHARGING_STATE&mf=BATTERY_LEVEL&mf=BLEID_DDADATA&mf=CHARGING_PROFILES&mf=CHARGING_SUMMARY&mf=CLIMATIZER_STATE&mf=DEPARTURES&mf=E_RANGE&mf=FUEL_LEVEL&mf=FUEL_RESERVE&mf=GLOBAL_PRIVACY_MODE&mf=GPS_LOCATION&mf=HEATING_STATE&mf=INTERMEDIATE_SERVICE_RANGE&mf=INTERMEDIATE_SERVICE_TIME&mf=LOCK_STATE_VEHICLE&mf=MAIN_SERVICE_RANGE&mf=MAIN_SERVICE_TIME&mf=MILEAGE&mf=OIL_LEVEL_CURRENT&mf=OIL_LEVEL_MAX&mf=OIL_LEVEL_MIN_WARNING&mf=OIL_SERVICE_RANGE&mf=OIL_SERVICE_TIME&mf=OPEN_STATE_CHARGE_FLAP_LEFT&mf=OPEN_STATE_CHARGE_FLAP_RIGHT&mf=OPEN_STATE_DOOR_FRONT_LEFT&mf=OPEN_STATE_DOOR_FRONT_RIGHT&mf=OPEN_STATE_DOOR_REAR_LEFT&mf=OPEN_STATE_DOOR_REAR_RIGHT&mf=OPEN_STATE_LID_FRONT&mf=OPEN_STATE_LID_REAR&mf=OPEN_STATE_SERVICE_FLAP&mf=OPEN_STATE_SPOILER&mf=OPEN_STATE_SUNROOF&mf=OPEN_STATE_TOP&mf=OPEN_STATE_WINDOW_FRONT_LEFT&mf=OPEN_STATE_WINDOW_FRONT_RIGHT&mf=OPEN_STATE_WINDOW_REAR_LEFT&mf=OPEN_STATE_WINDOW_REAR_RIGHT&mf=PAIRING_CODE&mf=PARKING_BRAKE&mf=PARKING_LIGHT&mf=PRED_PRECON_LOCATION_EXCEPTIONS&mf=PRED_PRECON_USER_SETTINGS&mf=RANGE&mf=REMOTE_ACCESS_AUTHORIZATION&mf=SERVICE_PREDICTIONS&mf=THEFT_STATE&mf=TIMERS&mf=VTS_MODES&wakeUpJob=19caa392-8500-4404-b79a-dbb71b453e72
DEBUG:pyporscheconnectapi.connection:Request body: b''
DEBUG:httpcore.connection:connect_tcp.started host='api.ppa.porsche.com' port=443 local_address=None timeout=5.0 socket_options=None
DEBUG:httpcore.connection:connect_tcp.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x7f536ac15430>
DEBUG:httpcore.connection:start_tls.started ssl_context=<ssl.SSLContext object at 0x7f536acbea40> server_hostname='api.ppa.porsche.com' timeout=5.0
DEBUG:httpcore.connection:start_tls.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x7f536ac8b220>
DEBUG:httpcore.http11:send_request_headers.started request=<Request [b'GET']>
DEBUG:httpcore.http11:send_request_headers.complete
DEBUG:httpcore.http11:send_request_body.started request=<Request [b'GET']>
DEBUG:httpcore.http11:send_request_body.complete
DEBUG:httpcore.http11:receive_response_headers.started request=<Request [b'GET']>
DEBUG:httpcore.http11:receive_response_headers.complete return_value=(b'HTTP/1.1', 400, b'Bad Request', [(b'Date', b'Sat, 02 Nov 2024 10:17:38 GMT'), (b'Content-Type', b'application/json'), (b'Content-Length', b'229'), (b'Connection', b'keep-alive'), (b'cache-control', b'no-cache, no-store, max-age=0, must-revalidate'), (b'pragma', b'no-cache'), (b'expires', b'0'), (b'x-content-type-options', b'nosniff'), (b'strict-transport-security', b'max-age=31536000 ; includeSubDomains'), (b'x-frame-options', b'DENY'), (b'x-xss-protection', b'0'), (b'referrer-policy', b'no-referrer')])
INFO:httpx:HTTP Request: GET https://api.ppa.porsche.com/app/connect/v1/vehicles/WP1ZZZXXX?mf=ACV_STATE&mf=ALARM_STATE&mf=BATTERY_CHARGING_STATE&mf=BATTERY_LEVEL&mf=BLEID_DDADATA&mf=CHARGING_PROFILES&mf=CHARGING_SUMMARY&mf=CLIMATIZER_STATE&mf=DEPARTURES&mf=E_RANGE&mf=FUEL_LEVEL&mf=FUEL_RESERVE&mf=GLOBAL_PRIVACY_MODE&mf=GPS_LOCATION&mf=HEATING_STATE&mf=INTERMEDIATE_SERVICE_RANGE&mf=INTERMEDIATE_SERVICE_TIME&mf=LOCK_STATE_VEHICLE&mf=MAIN_SERVICE_RANGE&mf=MAIN_SERVICE_TIME&mf=MILEAGE&mf=OIL_LEVEL_CURRENT&mf=OIL_LEVEL_MAX&mf=OIL_LEVEL_MIN_WARNING&mf=OIL_SERVICE_RANGE&mf=OIL_SERVICE_TIME&mf=OPEN_STATE_CHARGE_FLAP_LEFT&mf=OPEN_STATE_CHARGE_FLAP_RIGHT&mf=OPEN_STATE_DOOR_FRONT_LEFT&mf=OPEN_STATE_DOOR_FRONT_RIGHT&mf=OPEN_STATE_DOOR_REAR_LEFT&mf=OPEN_STATE_DOOR_REAR_RIGHT&mf=OPEN_STATE_LID_FRONT&mf=OPEN_STATE_LID_REAR&mf=OPEN_STATE_SERVICE_FLAP&mf=OPEN_STATE_SPOILER&mf=OPEN_STATE_SUNROOF&mf=OPEN_STATE_TOP&mf=OPEN_STATE_WINDOW_FRONT_LEFT&mf=OPEN_STATE_WINDOW_FRONT_RIGHT&mf=OPEN_STATE_WINDOW_REAR_LEFT&mf=OPEN_STATE_WINDOW_REAR_RIGHT&mf=PAIRING_CODE&mf=PARKING_BRAKE&mf=PARKING_LIGHT&mf=PRED_PRECON_LOCATION_EXCEPTIONS&mf=PRED_PRECON_USER_SETTINGS&mf=RANGE&mf=REMOTE_ACCESS_AUTHORIZATION&mf=SERVICE_PREDICTIONS&mf=THEFT_STATE&mf=TIMERS&mf=VTS_MODES&wakeUpJob=19caa392-8500-4404-b79a-dbb71b453e72 "HTTP/1.1 400 Bad Request"
DEBUG:httpcore.http11:receive_response_body.started request=<Request [b'GET']>
DEBUG:httpcore.http11:receive_response_body.complete
DEBUG:httpcore.http11:response_closed.started
DEBUG:httpcore.http11:response_closed.complete
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/connection.py", line 100, in request
    resp.raise_for_status()
  File "/usr/local/lib/python3.8/dist-packages/httpx/_models.py", line 763, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://api.ppa.porsche.com/app/connect/v1/vehicles/WP1ZZZXXX?mf=ACV_STATE&mf=ALARM_STATE&mf=BATTERY_CHARGING_STATE&mf=BATTERY_LEVEL&mf=BLEID_DDADATA&mf=CHARGING_PROFILES&mf=CHARGING_SUMMARY&mf=CLIMATIZER_STATE&mf=DEPARTURES&mf=E_RANGE&mf=FUEL_LEVEL&mf=FUEL_RESERVE&mf=GLOBAL_PRIVACY_MODE&mf=GPS_LOCATION&mf=HEATING_STATE&mf=INTERMEDIATE_SERVICE_RANGE&mf=INTERMEDIATE_SERVICE_TIME&mf=LOCK_STATE_VEHICLE&mf=MAIN_SERVICE_RANGE&mf=MAIN_SERVICE_TIME&mf=MILEAGE&mf=OIL_LEVEL_CURRENT&mf=OIL_LEVEL_MAX&mf=OIL_LEVEL_MIN_WARNING&mf=OIL_SERVICE_RANGE&mf=OIL_SERVICE_TIME&mf=OPEN_STATE_CHARGE_FLAP_LEFT&mf=OPEN_STATE_CHARGE_FLAP_RIGHT&mf=OPEN_STATE_DOOR_FRONT_LEFT&mf=OPEN_STATE_DOOR_FRONT_RIGHT&mf=OPEN_STATE_DOOR_REAR_LEFT&mf=OPEN_STATE_DOOR_REAR_RIGHT&mf=OPEN_STATE_LID_FRONT&mf=OPEN_STATE_LID_REAR&mf=OPEN_STATE_SERVICE_FLAP&mf=OPEN_STATE_SPOILER&mf=OPEN_STATE_SUNROOF&mf=OPEN_STATE_TOP&mf=OPEN_STATE_WINDOW_FRONT_LEFT&mf=OPEN_STATE_WINDOW_FRONT_RIGHT&mf=OPEN_STATE_WINDOW_REAR_LEFT&mf=OPEN_STATE_WINDOW_REAR_RIGHT&mf=PAIRING_CODE&mf=PARKING_BRAKE&mf=PARKING_LIGHT&mf=PRED_PRECON_LOCATION_EXCEPTIONS&mf=PRED_PRECON_USER_SETTINGS&mf=RANGE&mf=REMOTE_ACCESS_AUTHORIZATION&mf=SERVICE_PREDICTIONS&mf=THEFT_STATE&mf=TIMERS&mf=VTS_MODES&wakeUpJob=19caa392-8500-4404-b79a-dbb71b453e72'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/porschecli", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/cli.py", line 157, in cli
    loop.run_until_complete(main(args))
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/cli.py", line 64, in main
    data = await client.getCurrentOverview(vin)
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/client.py", line 53, in getCurrentOverview
    data = await self._connection.get(
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/connection.py", line 79, in get
    return await self.request("GET", url, params=params)
  File "/usr/local/lib/python3.8/dist-packages/pyporscheconnectapi/connection.py", line 103, in request
    raise PorscheException(exception_.response.status_code)
pyporscheconnectapi.exceptions.PorscheException

Before I got answers, but those were not useful in any way.
The Porsche App can read the state of the car.

porschecli overview -v "WP1ZZZ9YZNDA15232"

{
 "vin": "WP1ZZZXXX",
 "modelName": "Cayenne E-Hybrid",
 "customName": "XXX",
 "modelType": {
   "code": "9YAAE1",
   "year": "2022",
   "steeringPosition": "LEFT_HAND_DRIVE",
   "body": "SUV",
   "generation": "E3",
   "revision": 1,
   "model": "CAYENNE",
   "engine": "PHEV"
 },
 "systemInfo": {
   "driverExperience": "0.5",
   "privacyStyle": 1
 },
 "exteriorColorName": "tiefschwarzmetallic/tiefschwarzmetallic",
 "color": {
   "primaryExteriorColor": "000000"
 },
 "connect": false,
 "timestamp": "2024-11-02T10:11:57Z",
 "commands": [],
 "measurements": [
   {
     "key": "MAIN_SERVICE_RANGE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "PRED_PRECON_LOCATION_EXCEPTIONS",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "REMOTE_ACCESS_AUTHORIZATION",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "HEATING_STATE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "E_RANGE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_WINDOW_FRONT_LEFT",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "PAIRING_CODE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "RANGE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "TIMERS",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_SPOILER",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "GLOBAL_PRIVACY_MODE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "MILEAGE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "CHARGING_PROFILES",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "CHARGING_SUMMARY",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "THEFT_STATE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "SERVICE_PREDICTIONS",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_CHARGE_FLAP_LEFT",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "BATTERY_LEVEL",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OIL_LEVEL_MIN_WARNING",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "BATTERY_CHARGING_STATE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OIL_SERVICE_TIME",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "PARKING_LIGHT",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_LID_REAR",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "CLIMATIZER_STATE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OIL_LEVEL_MAX",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "FUEL_RESERVE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_DOOR_REAR_RIGHT",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "INTERMEDIATE_SERVICE_TIME",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "MAIN_SERVICE_TIME",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "ACV_STATE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_WINDOW_REAR_LEFT",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_LID_FRONT",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "BLEID_DDADATA",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "LOCK_STATE_VEHICLE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_DOOR_FRONT_LEFT",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_CHARGE_FLAP_RIGHT",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_WINDOW_REAR_RIGHT",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "ALARM_STATE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "GPS_LOCATION",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_DOOR_FRONT_RIGHT",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_DOOR_REAR_LEFT",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_SUNROOF",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_TOP",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "PRED_PRECON_USER_SETTINGS",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OIL_LEVEL_CURRENT",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "VTS_MODES",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "INTERMEDIATE_SERVICE_RANGE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OIL_SERVICE_RANGE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_SERVICE_FLAP",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "PARKING_BRAKE",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "FUEL_LEVEL",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "DEPARTURES",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   },
   {
     "key": "OPEN_STATE_WINDOW_FRONT_RIGHT",
     "status": {
       "isEnabled": false,
       "cause": "NOT_CONNECTED"
     }
   }
 ]
}

Waiting some minutes and logging into "My Porsche" on the web it works again and the answers are more complete (some values are there showin isEnabled = true) but still no odometer reading etc.

Any ideas?

@wingrunr21
Copy link

How often are you pulling information? You are asking for the current vehicle overview which requires talking to the car. I know my Taycan will sometimes intermittently show up as in privacy mode inside my garage (even in the Porsche app).

@MarkusGH
Copy link

MarkusGH commented Nov 2, 2024

Looks like querying too often will give error 400.
But I have not seen any useful information returned yet.

@wingrunr21
Copy link

wingrunr21 commented Nov 2, 2024

Which of those data fields show up in the Porsche app? Also, how often were you querying?

@MarkusGH
Copy link

MarkusGH commented Nov 2, 2024

The Porsche app shows all information, the car is not in privacy mode. For example odometer and SOC are displayed.

@MarkusGH
Copy link

MarkusGH commented Nov 2, 2024

And the information is missing right from the first query.

@fredriklj
Copy link
Collaborator

@MarkusGH Can you post the output from when you do get some readings ("some values are there showin isEnabled = true")? I have seen cases where the car goes offline, and then it looks quite like output you have posted. In those cases the App seem to show last known values, but is also unable to update to current/actual readings.

@fredriklj
Copy link
Collaborator

fredriklj commented Nov 3, 2024

@MarkusGH @wingrunr21 I can replicate this as well with the new auth-flow and httpx. It still works using the old client, so there is something that was introduced here. I added a timeout parameter to account to requests that takes longer than 5 seconds. Will also double-check all headers etc, to see they are set correctly.

Edit: Ok, I found it I think, see ed1b51c .. can you please pull and try again?

@MarkusGH
Copy link

MarkusGH commented Nov 3, 2024

I tried and it looks good now (as far as I can tell)

@augmentedtraffic
Copy link
Author

I can also confirm the latest on new_api continues to work. thanks I appreciate very much the work being done on this library.

@jwinston100
Copy link

Thank you for everyone's work, but it doesn't doesn't seem to work for me. I am using the API via Home Assistant's Porsche integration, so perhaps that integration still needs to be updated. I still receive this error:

This error originated from a custom integration.

Logger: custom_components.porscheconnect
Source: helpers/update_coordinator.py:354
integration: Porsche Connect (documentation, issues)
First occurred: November 3, 2024 at 7:21:40 AM (21 occurrences)
Last logged: 1:51:56 PM

Unexpected error fetching porscheconnect data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/porscheconnect/init.py", line 213, in _async_update_data
vehicle["name"] = summary["nickName"] or summary["modelDescription"]
~~~~~~~^^^^^^^^^^^^
KeyError: 'nickName'

@fredriklj
Copy link
Collaborator

@jwinston100 You have not updated ha-porscheconnect to the latest version.

@jwinston100
Copy link

@fredriklj Thanks for your answer, but I am using the latest version of ha-porscheconnect, version 0.0.18, from 12/2/2023. I don't see any updates beyond that version at https://github.com/CJNE/ha-porscheconnect/releases.

@fredriklj
Copy link
Collaborator

@jwinston100 See second post in this thread. Development is ongoing in this branch:

https://github.com/CJNE/pyporscheconnectapi/tree/new_api

@Jimnaldo
Copy link

Jimnaldo commented Nov 7, 2024

@fredriklj i keep getting this error:

Logger: homeassistant.util.package
Source: util/package.py:150
First occurred: 11:36:38 AM (3 occurrences)
Last logged: 11:36:38 AM

Unable to install package pyporscheconnectapi==0.2.0: × No solution found when resolving dependencies: ╰─▶ Because there is no version of pyporscheconnectapi==0.2.0 and you require pyporscheconnectapi==0.2.0, we can conclude that your requirements are unsatisfiable.

But when i check in SSH pyporscheconnectapi 0.2.0 is installed:

➜ ~ pip3 install git+https://github.com/CJNE/pyporscheconnectapi.git@new_api
Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/
Collecting git+https://github.com/CJNE/pyporscheconnectapi.git@new_api
Cloning https://github.com/CJNE/pyporscheconnectapi.git (to revision new_api) to /tmp/pip-req-build-67bf2bu7
Running command git clone --filter=blob:none --quiet https://github.com/CJNE/pyporscheconnectapi.git /tmp/pip-req-build-67bf2bu7
Running command git checkout -b new_api --track origin/new_api
branch 'new_api' set up to track 'origin/new_api'.
Switched to a new branch 'new_api'
Resolved https://github.com/CJNE/pyporscheconnectapi.git to commit 50e50e6
Installing build dependencies ... |^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[B^[[done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: httpx<1 in /usr/lib/python3.12/site-packages (from pyporscheconnectapi==0.2.0) (0.27.2)
Requirement already satisfied: anyio in /usr/lib/python3.12/site-packages (from httpx<1->pyporscheconnectapi==0.2.0) (4.6.2.post1)
Requirement already satisfied: certifi in /usr/lib/python3.12/site-packages (from httpx<1->pyporscheconnectapi==0.2.0) (2024.8.30)
Requirement already satisfied: httpcore==1.* in /usr/lib/python3.12/site-packages (from httpx<1->pyporscheconnectapi==0.2.0) (1.0.6)
Requirement already satisfied: idna in /usr/lib/python3.12/site-packages (from httpx<1->pyporscheconnectapi==0.2.0) (3.10)
Requirement already satisfied: sniffio in /usr/lib/python3.12/site-packages (from httpx<1->pyporscheconnectapi==0.2.0) (1.3.1)
Requirement already satisfied: h11<0.15,>=0.13 in /usr/lib/python3.12/site-packages (from httpcore==1.*->httpx<1->pyporscheconnectapi==0.2.0) (0.14.0)

So i'm a bit lost, could you advise or someone else please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking Changes
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.