CJNE / pyporscheconnectapi

Python client library for Porsche Connect API
MIT License
44 stars 9 forks source link

some commands don't return data #6

Closed wkearney99 closed 2 years ago

wkearney99 commented 2 years ago

I posted about this on the home assistant forum.
https://community.home-assistant.io/t/porsche-connect/148913/10 I've repeated the info here.

These commands work, in that they return valid data:

list, summary and capabilities.

When I query a “cli position --vin XXXXXX” (with the correct VIN, obviously) I gives me back the error:

{
“pcckErrorKey”: null,
“pcckErrorMessage”: “Gray services are not offered for this vehicle.”,
“pcckErrorCode”: null,
“pcckIsBusinessError”: true
}

I believe I’ve got full subscription services paid up for this, am I missing something?

The same ‘gray services’ error also happens with triplongterm, tripshortterm, speedalerts and theftalerts.

I have seen ‘theft alerts’ in the android app (alarm set off by someone still in the vehicle). So there is data “online” for that. I don’t have any speed or geo boundaries set for it.

Capabilities is odd in that seat heating is present in the vehicle, both front and rear. But I suspect this has more to do with not being able to de/activate them remotely. Also it returns engineType and carModel as “UNKNOWN”

$ ./cli.py --vin WP1XXXXX capabilities
{
“displayParkingBrake”: true,
“needsSPIN”: false,
“hasRDK”: true,
“engineType”: “UNKNOWN”,
“carModel”: “UNKNOWN”,
“onlineRemoteUpdateStatus”: null,
“heatingCapabilities”: {
“frontSeatHeatingAvailable”: false,
“rearSeatHeatingAvailable”: false
},
“steeringWheelPosition”: “LEFT”,
“hasHonkAndFlash”: false
}

Where would I have set a PIN code? If I try lock/unlock it prompts me for one. Trying something random throws this error:

$ ./cli.py --vin WPXXXXX unlock
PIN code:
Traceback (most recent call last):
File “./cli.py”, line 4, in
cli()
File “/home/wkearney/projects/porsche/pyporscheconnectapi/pyporscheconnectapi/cli.py”, line 125, 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 “/home/wkearney/projects/porsche/pyporscheconnectapi/pyporscheconnectapi/cli.py”, line 91, in main
data = await client.unlock(vin, pin, waitForConfirmation = not args.nowait)
File “/home/wkearney/projects/porsche/pyporscheconnectapi/pyporscheconnectapi/client.py”, line 168, in unlock
return await self._lockUnlock(vin, pin, ‘unlock’, waitForConfirmation=waitForConfirmation)
File “/home/wkearney/projects/porsche/pyporscheconnectapi/pyporscheconnectapi/client.py”, line 34, in _lockUnlock
result = await self._spinner(f"https://api.porsche.com/service-vehicle/remote-lock-unlock/{vin}/{progressResult[‘requestId’]}/status")
KeyError: ‘requestId’
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f4c676f7220>
ERROR:asyncio:Unclosed connector
connections: [’[(<aiohttp.client_proto.ResponseHandler object at 0x7f4c67715a60>, 7499699.935139161)]’]
connector: <aiohttp.connector.TCPConnector object at 0x7f4c676f7280>

overview throws this error:

$ cli.py --vin WP1XXXX overview Traceback (most recent call last): File “./cli.py”, line 4, in cli() File “/home/wkearney/projects/porsche/pyporscheconnectapi/pyporscheconnectapi/cli.py”, line 125, 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 “/home/wkearney/projects/porsche/pyporscheconnectapi/pyporscheconnectapi/cli.py”, line 57, in main data = await client.getCurrentOverview(vin) File “/home/wkearney/projects/porsche/pyporscheconnectapi/pyporscheconnectapi/client.py”, line 192, in getCurrentOverview spinnerResult = await self._spinner(f"https://api.porsche.com/service-vehicle/se/sv_SE/vehicle-data/{vin}/current/request/{progressResult[‘requestId’]}/status") KeyError: ‘requestId’ ERROR:asyncio:Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x7f4612ff3190> ERROR:asyncio:Unclosed connector connections: [’[(<aiohttp.client_proto.ResponseHandler object at 0x7f461300aa60>, 7499233.125293788)]’] connector: <aiohttp.connector.TCPConnector object at 0x7f4612ff31f0>

emobility errors out with:

{
“pcckErrorKey”: “GRAY_SLICE_ERROR_UNKNOWN_MSG”,
“pcckErrorMessage”: null,
“pcckErrorCode”: null,
“pcckIsBusinessError”: true
}

Likewise climate-on and climate-off also throw an error. But I don’t believe the non-EV variants can even DO remote climate controlling (it doesn’t show up as an option in the Porsche android app). Same with directcharge-on and directcharge-off.

CJNE commented 2 years ago

Thank you! It looks like some functionality is missing for your car or perhaps it's done in a different way. First we need to figure out if the functionality is supposed to work at all for your car. If you log in the my.porsche.com and go to your car, is there a list with activated services? For lock/unlock i believe the service "Car control" needs to be active. For air conditioning i believe "E-mobility" needs to be active. I'll take a look at adding support in the library for figuring out capabilities and what services are enabled.

wkearney99 commented 2 years ago

No doubt the charge functionality isn't going to be present in the non-EV variants. I'd wonder how the hybrid models report data.

When I look at https://my.porsche.com/core/us/en_US/vehicles/WPXXXX#services (WPXXXX being my VIN) I don't see anything called "Activated Services". I do see a "My Connect Services" section and it has News, Portal POIs and Twitter listed under a "Configurable services" group. Do you have something else shown on your page at that URL?

wkearney99 commented 2 years ago

(my apologies for the edits, I'm not familiar enough with github's editing markup)

Here's a run-down on what I can see/do in the "Car Connect" Android app. I post this because it seems to represent what 'can' be gotten 'from Porsche' regarding my vehicle. I don't know which online services it uses to get/do this.

There is a Remote menu that will let me control locking the doors and folding the mirrors. This is the only 'control' I have of the vehicle from the app. There are no climate nor charging options.

There's a Status menu that shows these tabs:

Ignition state (on|off)
Speed 
Mileage
Fuel level
Fuel range 
The vehicle position on a map (with a fuel range circle overlaid)
It also presents service interval data, though I don't know if this comes from the vehicle or from the Porsche database.  
It shows me Service, Intermediate service and Oil change; with a mileage interval and days.  

The last tab presents Tire Pressure Monitoring, with what I think is a suggested adjustment value? Not actual PSI integers for the current pressure. It's showing 0/0 front and -1/-1 for rear, which I'm assuming means it suggests dropping 1 psi on the rear tires?`

There's a Trip menu that shows Last trip and Total trip tabs; each with Travel time, Distance, Consumption and Speed.

Lastly an Info menu gives me Model, Color, Plate# and VIN.

Jmi91 commented 2 years ago

Same problem for me. Overview command show invalid data and take a lot of time. list, summary and capabilities commands are working fine. I have a Porsche Taycan.

root@computer:~# /usr/local/bin/porschecli -e "email@email.com" -p "password" -v "WP0XXXXXXX" overview { "vin": "WP0XXXXXXX", "oilLevel": null, "fuelLevel": null, "batteryLevel": null, "remainingRanges": { "conventionalRange": null, "electricalRange": null }, "mileage": null, "parkingLight": "INVALID", "parkingLightStatus": null, "parkingBreak": "INVALID", ... ...

wkearney99 commented 2 years ago

If I follow the Porsche store links it eventually takes me over to the Vodaphone website, on which I show active subscriptions to Remote Services and Security Services. I have one user on the account, and one phone. I've never seen anywhere to set a PIN.

Jmi91 commented 2 years ago

So all is working for me today... I think it was a problem with the Porsche server for a few days...

CJNE commented 2 years ago

If I follow the Porsche store links it eventually takes me over to the Vodaphone website, on which I show active subscriptions to Remote Services and Security Services. I have one user on the account, and one phone. I've never seen anywhere to set a PIN.

Can you unlock the car with the app without entering a PIN code? It might be a separate API for your version. Can you access your car from the "My Porsche" website as well?

I've added a new cli command: services: porschecli --vin WPXXXXX services

the output for my Taycan is:

  "vehicleServiceEnabledMap": {
    "RAH": "HIDDEN",
    "RPC": "ENABLED",
    "CF": "ENABLED",
    "CN": "ENABLED",
    "ORU": "ENABLED",
    "RBC": "ENABLED",
    "TAP": "ENABLED",
    "GF": "ENABLED",
    "RTS": "ENABLED",
    "SA": "ENABLED",
    "CC": "ENABLED"
  },
  "serviceAccessDetails": [
    {
      "serviceId": "rclima_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [
        "RPC",
        "RBC"
      ],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "statusreport_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [
        "CC"
      ],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "uota_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [
        "ORU"
      ],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "carfinder_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [
        "CF"
      ],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "rhonk_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "mond_applemusic_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "mond_applepodcasts_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "speedalert_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [
        "SA"
      ],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "rolesrights_authorization_v2",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "rprofilesandtimer_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "dwap",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [
        "TAP"
      ],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "trip_statistic_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [
        "RTS"
      ],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "rlu_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [
        "CC"
      ],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "geofence_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [
        "GF"
      ],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "rbatterycharge_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [
        "RPC",
        "RBC"
      ],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "nc_destsync_v2",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [
        "CN"
      ],
      "actionUrl": null,
      "isConfigurable": null
    },
    {
      "serviceId": "otafc_predmaint_v1",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [],
      "actionUrl": null,
      "isConfigurable": null
    }
  ]
}

How does it look for you? (hint, encluse the output with triple backslashes in this editor for nice formatting)

wkearney99 commented 2 years ago

Mine does not report anywhere near the same amount of info.

I notice the code uses different URLs for different languages and countries. But some URLs are fixed on 'se' and 'sv_SE'. I'm in the US, using en_US (via the ~/.porschecli.conf file. I'd wonder if it'd make any difference if I used other combinations?

Is there a debug flag or something I could enable to see more of the live data?

porschecli  --vin "WPXXXXX" services
{
  "vehicleServiceEnabledMap": {
    "RTS": "HIDDEN",
    "CN": "HIDDEN",
    "RAH": "HIDDEN",
    "SA": "HIDDEN",
    "TAP": "HIDDEN",
    "CC": "HIDDEN",
    "GF": "HIDDEN",
    "RBC": "HIDDEN",
    "ORU": "HIDDEN",
    "CF": "HIDDEN",
    "RPC": "HIDDEN"
  },
  "serviceAccessDetails": [
    {
      "serviceId": "rolesrights_authorization_v2",
      "disabled": false,
      "disabledReason": null,
      "dependingServices": [],
      "actionUrl": null,
      "isConfigurable": null
    }
  ]
}
wkearney99 commented 2 years ago

I tried various combinations of country, language and timezone and none seem to make any difference. Bogus ones fail though, so there must be some sort of checking at the API side.

Is there any documentation on this available anywhere? Officially, or otherwise?

CJNE commented 2 years ago

Thanks for testing @wkearney99

Unfortunately i have some bad news! The locale options will not make any difference, the services call don't include any such data. (there is a -d (or --debug) option that can be used to see the requests)

I did some research and it looks like Cayenne II does not have support for Porsche Connect, this was introduces for Cayenne III. The same goes for Panamera, Macan and 718 without navigation. Those models instead have support for something called Porsche Car Connect which is a completely different system.

So this explains why only a very limited set of commands work for your car. For the moment at least i don't have the possibility to research and implement Porsche Car Connect, it might be something i can have a look at in a later stage. I'll update the readme and make the library not trying to access the API for unsupported models.

wkearney99 commented 2 years ago

Well, leave the ability to connect for at least the list and overview.

Right, "Car Connect" is the name of the Android app.

My main interest is to have the position info and the ability to send a lock command. I'd very much like to geo-fence for the location, and be able to double-check that it's locked each evening. Using the fold mirror command when I'm parked in an area known for narrow streets would be an added bonus, but not as important.