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 · 39 comments
Open

APIs changed? #46

augmentedtraffic opened this issue Jun 11, 2024 · 39 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.

@Ayuus
Copy link

Ayuus commented Jul 8, 2024

@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

Tried this, but does not work for me.
Loading integration fails with error message "Config-flow could not be loaded: 500 Internal Server Error Server got itself in trouble"

HA System log:

Logger: homeassistant.util.package
Bron: util/package.py:123
Eerst voorgekomen: 22:26:10 (3 gebeurtenissen)
Laatst gelogd: 22:26:18

Unable to install package pyporscheconnectapi==0.2.0: ERROR: Could not find a version that satisfies the requirement pyporscheconnectapi==0.2.0 (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.12, 0.0.13, 0.0.14, 0.0.15, 0.0.16, 0.0.17, 0.0.19, 0.0.20, 0.0.22, 0.0.23, 0.0.24, 0.0.25, 0.0.26, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7) ERROR: No matching distribution found for pyporscheconnectapi==0.2.0

Any idea what could be wrong?

I used Advanced SSH & Web Terminal for installing the library. Using normal SSH & Termnal add-on did not allow me to use pip3. After install: I get warning:

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

Could that be the cause?

@wingrunr21
Copy link

wingrunr21 commented Jul 10, 2024

  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.

I haven't gotten time to put together a PR but I'm pretty sure this is because you are just re-requesting the token with your grant code vs using the refresh token flow. Porsche is using Auth0 and their docs on the refresh token seem to be accurate. I did test this with my Postman collection and I was able to refresh a token with the refresh code 12+ hours later (which is actually somewhat interesting they are this loose but that's a digression).

@fredriklj
Copy link
Collaborator

Thanks for the tip, @wingrunr21. I tried the refresh token flow, and it works fine. I can renew the access token that way, but still run into the 429 status code. I might have overlooked something, have not had time to dig deeper into the issue, but if you are having any success I'd be much interested in hearing about it!

@wingrunr21
Copy link

Did you push the updated flow to Github?

@fredriklj
Copy link
Collaborator

No, since it didn't solve it.. I've been on vacation, so have had other priorities. But did some testing, and the problem seems related to the connection rather than to the requests themselves. Could be that we maintain the connections for what the gateway thinks is too long. I've been trying to force connections to close, but sometimes that doesn't work, for reasons I can't figure out. And when it does, hass gets really mad at me. It's also a struggle to debug what is happening behind the curtains of aiohttp.

I'm contemplating switching it out for httpx, just to see if that works better. Shouldn't be much work, but have not had the time to do it.

@Jimnaldo
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

Tried this, but does not work for me. Loading integration fails with error message "Config-flow could not be loaded: 500 Internal Server Error Server got itself in trouble"

HA System log:

Logger: homeassistant.util.package
Bron: util/package.py:123
Eerst voorgekomen: 22:26:10 (3 gebeurtenissen)
Laatst gelogd: 22:26:18

Unable to install package pyporscheconnectapi==0.2.0: ERROR: Could not find a version that satisfies the requirement pyporscheconnectapi==0.2.0 (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.12, 0.0.13, 0.0.14, 0.0.15, 0.0.16, 0.0.17, 0.0.19, 0.0.20, 0.0.22, 0.0.23, 0.0.24, 0.0.25, 0.0.26, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7) ERROR: No matching distribution found for pyporscheconnectapi==0.2.0

Any idea what could be wrong?

I used Advanced SSH & Web Terminal for installing the library. Using normal SSH & Termnal add-on did not allow me to use pip3. After install: I get warning:

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

Could that be the cause?

i have the same problem, please advise?

@CTRDevelopments
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

Tried this, but does not work for me. Loading integration fails with error message "Config-flow could not be loaded: 500 Internal Server Error Server got itself in trouble"
HA System log:

Logger: homeassistant.util.package
Bron: util/package.py:123
Eerst voorgekomen: 22:26:10 (3 gebeurtenissen)
Laatst gelogd: 22:26:18

Unable to install package pyporscheconnectapi==0.2.0: ERROR: Could not find a version that satisfies the requirement pyporscheconnectapi==0.2.0 (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.12, 0.0.13, 0.0.14, 0.0.15, 0.0.16, 0.0.17, 0.0.19, 0.0.20, 0.0.22, 0.0.23, 0.0.24, 0.0.25, 0.0.26, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7) ERROR: No matching distribution found for pyporscheconnectapi==0.2.0

Any idea what could be wrong?
I used Advanced SSH & Web Terminal for installing the library. Using normal SSH & Termnal add-on did not allow me to use pip3. After install: I get warning:
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Could that be the cause?

i have the same problem, please advise?

Unfortunately I couldn't get this to work. Hoping the kind devs will get it into a more simple installation state when it's ready, something like HACS as the original version, so that I can use it. Sorry I cannot be more help

@fredriklj
Copy link
Collaborator

@wingrunr21 Ok, so I tried out httpx as well, and got into the same rate limiting issue after 3 hrs. But at least a bit wiser. It seems they REALLY don't want anyone to poll the API with regular intervals. I will try some ridiculously long interval and to do on-demand refresh when needed.

I'll push the refresh token flow to the repo, if you would like to have a look and see if it makes sense.

@fredriklj
Copy link
Collaborator

@CTRDevelopments Once/if we get this working again, we'll do a proper release and update the hass component accordingly. Currently we're struggling to get some meaningful functionality from the APIs, due to very strict rate limiting. Just keep an eye on this issue.

@augmentedtraffic
Copy link
Author

augmentedtraffic commented Aug 4, 2024

UPDATE --- not an API issue or even a Porsche issue but related to the car not being driven for a while and hence for some reason it's status update was stale (until I turned the car on again after a long period of time - i.e. > 1 week). I haven't seen this behavior. To confirm the APIs work OK now for both cars.


Just some information - I have two cars one a 2024 911 and other 2023 Panamera - the responses are different. For the past 8 or so hours I am seeing different responses for the two cars (also on the mobile app it is "Stuck" trying to refresh the lock data etc only for the Pana). In the code, I see the following exception for the pana - to confirm the 911 is working OK.

I suspect it is a Porsche issue as the mobile app seems to have similar behavior (i.e. 911 is refreshed but the Pana isn't)

Just wanted you all to be aware (as I initially thought it wasn't working for both cars but I changed the logic to simply ignore for just the one car instead of quit entirely). I always now check the mobile app behavior to confirm any "issues" first.

Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/pyporscheconnectapi/connection.py", line 338, in get
return await resp.json()
File "/usr/local/lib/python3.7/dist-packages/aiohttp/client_reqrep.py", line 1111, in json
headers=self.headers,
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('https://api.ppa.porsche.com/app/connect/v1/vehicles/***redacted***?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=92b257cd-e435-4dae-9308-9952cf37661b')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./porsche1.py", line 148, in
loop.run_until_complete(vehicles())
File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "./porsche1.py", line 63, in vehicles
data = await client.getCurrentOverview(vin)
File "/usr/local/lib/python3.7/dist-packages/pyporscheconnectapi/client.py", line 56, in getCurrentOverview
f"https://api.ppa.porsche.com/app/connect/v1/vehicles/{vin}?{measurements+wakeup}"
File "/usr/local/lib/python3.7/dist-packages/pyporscheconnectapi/connection.py", line 340, in get
raise PorscheException(exception_.status)
pyporscheconnectapi.exceptions.PorscheException
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x758e9d90>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x75025340>, 1077379.39213957)]']
connector: <aiohttp.connector.TCPConnector object at 0x758e9db0>

@fredriklj
Copy link
Collaborator

Thanks @augmentedtraffic .. I've seen such timeouts myself when the car seem to have lost contact with the backend, for some time. We need to add better handling of such failures.

What I think I have found out is that one has to keep the regular polling interval above 30 minutes, then you can also do on-demand polling in between those regular pollings without hitting the 429 (Too many requests).

Hopefully I should be able to set aside some time to work on the API later this month, to add some more functionality and (as you have noted) better error handling.

@normanmaurer
Copy link

@fredriklj that's promising... thanks for all the efforts you put into this.

@jwinston100
Copy link

@augmentedtraffic I have driven my car frequently but still get the error:

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'

So I don't see how this isn't an issue with the Porsche API.

@augmentedtraffic
Copy link
Author

@augmentedtraffic I have driven my car frequently but still get the error:

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'

So I don't see how this isn't an issue with the Porsche API.

The error in your post is indeed a different error that I have not seen with the newer APIs/library versions. I don't use HA as I use the python library directly.

@jwinston100
Copy link

@augmentedtraffic I see. I was referred to this thread from the error I have which was reported at CJNE/ha-porscheconnect#245. Has anyone found a solution?

@fredriklj
Copy link
Collaborator

@jwinston100 Please see the posts in this issue. The APIs have been retired, and work is on-going to explore the new API.

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.

10 participants