-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
400 Error: PSA status API seems to have changed? #678
Comments
Yeah i'm getting the same :( Suddenly stopped working yesterday afternoon |
Thanks, this seems to solve the problem indeed. I don't know if this could be a long term fix but at least you are onto something ! |
Same issue here |
Is this solution? |
Thanks for your investigation into this issue. |
Getting the same error here since last night (e-208) :( |
You can manually edit the file in your docker container, wait until this docker gets updated or use my fork: |
the long term solution is to incorporate @mdkeil 's PR and release a new version that everyone can update to. Short term AND TEMPORARY for those running docker #Get the ID of the running image
#open a shell into the running container
#change to the correct folder #install your file editor of choice
#edit line 105 of psa_client.py from #save and restart the container This will all be deleted if you do an update, etc |
Thank you so much @sod75 and @GewoonJaap ! |
Thanks for quick patch guys 👍 |
You also have a couple other endpoints like unlock and horn that aren't in this one |
Yup, those are included as well :) |
Is there any manual how to resolve this for dummies like me? |
sod75 did a good tutorial above if you're running it in docker |
I found out that doing this might not actually work on all scenarios. I had to delete the matching .pyc file before restarting the container to have things running back as before Run find / -name psa_client*.pyc inside the container and remove the file In my case it was: |
Unfortunately, I need your help. I applied the change to psa_client.py as described. I removed as well the file in the __pychache. any hint? |
Did you reboot from within the container? That happened to me when I tried it that way. You have to edit the .py file, remove the .pyc file, exit the shell and do “docker restart” on the container. Then open a new shell and check if the changes remain (the pyc file is generated when you access the app webpage) |
the change don't survive a container reboot. You can create a bind mount from /host/mnt/psa_client.py (modified version) to /usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/psa_client.py |
@mdkeil thanks for the fast response and hints. you see, I don't have many clues on docker ... |
/host/mnt is a wildcard for an any folder at the host system 😉 |
FYI, instead of offering a stable API, stellantis explicitly states that one needs to keep up with the changes 😠
|
Ok so I've Home assistant OS with no access to SSH (have never configured it). How do I update to this version to get it all working again?? |
That is not what happened here. The API cannot handle an extra field in the request. So the API is not as flexible as they expect the users to be |
When I edit the file and restart the container. The change is gone. I also cannot use vi anymore and have to do the apt-get update etc again. Edit: exit the container and doing docker restart worked! |
Don't use restart from HA. When you have finished, just leave the docker instance (ctrl + d) and then use command |
I have HA OS. How can I fix this? |
Same issue here - how can I fix this in HA OS? |
In HA OS it is difficult. You can try the solution posted in the last comment here: |
400 HTTP Error when requesting vehicle status
as of (23/11/23)
To Reproduce
simply start program and if required call local endpoint http://localhost:5000/get_vehicleinfo/ to provoke status API call to PSA, or wait until program does it by itself...
Log output to console shows this: ( I have enabled HTTP debugging in urllib3 in addition to your application debugging, so you can see exactly what happens on the wire).
Note the 400 response payload indicates something to do with a Header error. (in bold below):
2023-11-24 09:50:08,107 DEBUG Starting new HTTPS connection (1): api.groupe-psa.com:443
2023-11-24 09:50:08,107 :: DEBUG :: Starting new HTTPS connection (1): api.groupe-psa.com:443
send: b'GET /connectedcar/v4/user/vehicles/1c8bedfe1bd229d9cf0fee6613462af127a77c0a3ca67b4cad3399856d40cad6f7e13d53f4930922a8159da20f738a579e576284871a4ddb840f3d72016cfad9248617be0f502e8de8b47c0ef511388e72acafd3bd348b2f0220e2956f14fe25e/status?extension=odometer&client_id=122f3511-4f74-4a0c-bcda-af2f3b2e3a65 HTTP/1.1\r\nHost: api.groupe-psa.com\r\nAccept-Encoding: identity\r\nAccept: application/hal+json\r\nUser-Agent: Swagger-Codegen/4.0/python\r\nAuthorization: Bearer <removed*>\r\nx-introspect-realm: clientsB2CVauxhall\r\nContent-Type: application/json\r\n\r\n'
reply: 'HTTP/1.1 400 Bad Request\r\n'
header: Connection: close
header: Date: Fri, 24 Nov 2023 09:50:07 GMT
header: Expires: 0
header: Cache-Control: no-store, no-cache, must-revalidate, private
header: Set-Cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Thu, 23-Nov-2023 09:50:07 GMT
header: Set-Cookie: JSESSIONID=Kv440m8cC1gwo0yaUoqbH1Q9ASwE7e0aTAOAfVhc; path=/
header: Strict-Transport-Security: max-age=15724800; includeSubDomains
header: Content-Type: application/hal+json
header: X-Global-Transaction-ID: 32486679656071cfda9a6a3f
header: User-Agent: Swagger-Codegen/4.0/python
header: Set-Cookie: PSACountry=GB; Domain=.groupe-psa.com; Path=/
2023-11-24 09:50:08,796 DEBUG https://api.groupe-psa.com:443 "GET /connectedcar/v4/user/vehicles/1c8bedfe1bd229d9cf0fee6613462af127a77c0a3ca67b4cad3399856d40cad6f7e13d53f4930922a8159da20f738a579e576284871a4ddb840f3d72016cfad9248617be0f502e8de8b47c0ef511388e72acafd3bd348b2f0220e2956f14fe25e/status?extension=odometer&client_id=122f3511-4f74-4a0c-bcda-af2f3b2e3a65 HTTP/1.1" 400 None
2023-11-24 09:50:08,796 :: DEBUG :: https://api.groupe-psa.com:443 "GET /connectedcar/v4/user/vehicles/1c8bedfe1bd229d9cf0fee6613462af127a77c0a3ca67b4cad3399856d40cad6f7e13d53f4930922a8159da20f738a579e576284871a4ddb840f3d72016cfad9248617be0f502e8de8b47c0ef511388e72acafd3bd348b2f0220e2956f14fe25e/status?extension=odometer&client_id=122f3511-4f74-4a0c-bcda-af2f3b2e3a65 HTTP/1.1" 400 None
2023-11-24 09:50:08,808 :: DEBUG :: response body: {"uuid":"35bb70e9-ff95-412a-bb7a-bbd287523323","code":40000,"message":" Invalid parameter: X-MPHSource","timestamp":"2023-11-24T09:50:07.941Z"}
2023-11-24 09:50:08,810 :: ERROR :: get_vehicle_info: ApiException: (400)
Reason: Bad Request
Environment (please complete the following information):
Possible Solution
Problem is resolved by removing [extension=odometer] query string property.
I have tested [with curl] the same API call without this parameter; it works successfully and odometer object appears to still be included in the response:
curl -v -k --header "Authorization: Bearer <removed>" --header "Host: api.groupe-psa.com" --header "x-introspect-realm: clientsB2CVauxhall" --header "Content-Type: application/json" --header "Accept: application/hal+json" --header "Accept-Encoding: identity" --get "https://api.groupe-psa.com/connectedcar/v4/user/vehicles/1c8bedfe1bd229d9cf0fee6613462af127a77c0a3ca67b4cad3399856d40cad6f7e13d53f4930922a8159da20f738a579e576284871a4ddb840f3d72016cfad9248617be0f502e8de8b47c0ef511388e72acafd3bd348b2f0220e2956f14fe25e/status?client_id=122f3511-4f74-4a0c-bcda-af2f3b2e3a65"
< HTTP/1.1 200 OK
< Connection: close
< Date: Fri, 24 Nov 2023 10:11:50 GMT
< Expires: 0
< Cache-Control: no-store, no-cache, must-revalidate, private
< Set-Cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Thu, 23-Nov-2023 10:11:50 GMT
< Set-Cookie: JSESSIONID=h7Yjbi8bexWqtQzc2j6zXF_b9twnqnWCq452p__T; path=/
< Strict-Transport-Security: max-age=15724800; includeSubDomains
< Content-Type: application/hal+json
< X-Global-Transaction-ID: 08f333a5656076e60298c23f
< User-Agent: curl/7.54.0
< Set-Cookie: PSACountry=GB; Domain=.groupe-psa.com; Path=/
<
(formatted for readability)
{
"createdAt": "2023-11-24T09:44:47Z",
"updatedAt": "2023-11-24T09:44:47Z",
"ignition": {
"createdAt": "2023-11-24T09:44:47Z",
"type": "Stop"
},
"battery": {
"voltage": 71.5,
"createdAt": "2023-11-24T09:44:47Z"
},
"privacy": {
"createdAt": "2023-11-24T09:44:47Z",
"state": "None"
},
"service": {
"createdAt": "2023-10-20T19:43:00Z",
"type": "Electric"
},
"environment": {
"luminosity": {
"createdAt": "2023-11-24T09:44:47Z",
"day": true
},
"air": {
"createdAt": "2023-11-24T09:44:47Z",
"temp": 8.5
}
},
"odometer": {
"createdAt": "2023-11-24T09:44:47Z",
"mileage": 6218.1
},
"_links": {
"self": {
"href": "https://api.groupe-psa.com/connectedcar/v4/user/vehicles/1c8bedfe1bd229d9cf0fee6613462af127a77c0a3ca67b4cad3399856d40cad6f7e13d53f4930922a8159da20f738a579e576284871a4ddb840f3d72016cfad9248617be0f502e8de8b47c0ef511388e72acafd3bd348b2f0220e2956f14fe25e/status?profile=endUser"
},
"vehicle": {
"href": "https://api.groupe-psa.com/connectedcar/v4/user/vehicles/1c8bedfe1bd229d9cf0fee6613462af127a77c0a3ca67b4cad3399856d40cad6f7e13d53f4930922a8159da20f738a579e576284871a4ddb840f3d72016cfad9248617be0f502e8de8b47c0ef511388e72acafd3bd348b2f0220e2956f14fe25e"
}
},
"preconditioning": {
"airConditioning": {
"createdAt": "2023-11-24T09:44:47Z",
"updatedAt": "2023-11-24T09:44:47Z",
"status": "Disabled",
"programs": [
{
"enabled": false,
"slot": 1,
"recurrence": "Daily",
"start": "PT0S"
},
{
"enabled": false,
"slot": 2,
"recurrence": "Daily",
"start": "PT0S"
},
{
"enabled": false,
"slot": 3,
"recurrence": "Daily",
"start": "PT0S"
},
{
"enabled": false,
"slot": 4,
"recurrence": "Daily",
"start": "PT0S"
}
]
}
},
"energies": [
{
"createdAt": "2023-11-24T09:44:47Z",
"type": "Electric",
"subType": "ElectricEnergy",
"level": 76,
"autonomy": 260,
"extension": {
"electric": {
"battery": {
"load": {
"createdAt": "2023-11-24T09:44:47Z",
"capacity": 36640,
"residual": 26304
}
},
"charging": {
"plugged": false,
"status": "Disconnected",
"chargingRate": 0,
"chargingMode": "No",
"nextDelayedTime": "PT30M"
}
}
}
}
],
"preconditionning": {
"airConditioning": {
"createdAt": "2023-11-24T09:44:47Z",
"updatedAt": "2023-11-24T09:44:47Z",
"status": "Disabled",
"programs": [
{
"enabled": false,
"slot": 1,
"recurrence": "Daily",
"start": "PT0S"
},
{
"enabled": false,
"slot": 2,
"recurrence": "Daily",
"start": "PT0S"
},
{
"enabled": false,
"slot": 3,
"recurrence": "Daily",
"start": "PT0S"
},
{
"enabled": false,
"slot": 4,
"recurrence": "Daily",
"start": "PT0S"
}
]
}
},
"energy": [
{
"createdAt": "2023-11-24T09:44:47Z",
"updatedAt": "2023-11-24T09:44:47Z",
"type": "Electric",
"level": 76,
"autonomy": 260,
"charging": {
"plugged": false,
"status": "Disconnected",
"chargingRate": 0,
"chargingMode": "No",
"nextDelayedTime": "PT30M"
}
}
]
}
The text was updated successfully, but these errors were encountered: