-
Notifications
You must be signed in to change notification settings - Fork 12
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
Comments
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. |
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 |
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. |
two ICEs - some parts redacted hope this helps - I think some things are slightly different even between the two cars. { { |
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 |
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 - 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?? |
Nevermind, I overrode the python library package with the version in the new_api branch. All good. Works again, thanks! |
@fredriklj , super. I have installed via PIP but how do i get the data? Sorry if this seems like a noobie type question. Cheers |
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) |
@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 |
@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. |
@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 |
The repo you need to clone into custom_components is here: |
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 |
@fredriklj just wanted to say that this works great at least for the "read-only" things together with |
@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. |
@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) |
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! 🎉 |
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. |
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 |
@CTRDevelopments this is what worked for me:
Restart homeassistant |
In case anyone has any good ideas, this is where I am currently stuck:
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. |
I can confirm that there are no issues after I changed the polling to 35min interval |
The |
@fredriklj any idea why this error occurs in HA: config flow could not be loaded: 500 Internal server error server got itself in trouble? |
Spoke too soon - left it running on a 32 minute polling interval and some time overnight got hit with the |
@fredriklj (or anyone else), have you tried a backoff function when you see the |
@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.
I moved to |
@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. |
I installed with
Am I doing something wrong here? |
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 |
Called
After some calls I get:
Did I hit a rate limit or is there another issue? |
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? |
It works again - no idea. |
you could turn on debug logging via the CLI option. there's pretty extensive logging through the library |
OK - error 400 raised its ugly head again:
Before I got answers, but those were not useful in any way.
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? |
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). |
Looks like querying too often will give error 400. |
Which of those data fields show up in the Porsche app? Also, how often were you querying? |
The Porsche app shows all information, the car is not in privacy mode. For example odometer and SOC are displayed. |
And the information is missing right from the first query. |
@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. |
@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? |
I tried and it looks good now (as far as I can tell) |
I can also confirm the latest on new_api continues to work. thanks I appreciate very much the work being done on this library. |
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 Unexpected error fetching porscheconnect data |
@jwinston100 You have not updated ha-porscheconnect to the latest version. |
@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. |
@jwinston100 See second post in this thread. Development is ongoing in this branch: |
@fredriklj i keep getting this error: Logger: homeassistant.util.package 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 So i'm a bit lost, could you advise or someone else please? |
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
The text was updated successfully, but these errors were encountered: