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

"Can't refresh remote token" and "RateLimitException" visible in log and not able to start/stop charging or refresh status #967

Open
Jordan87 opened this issue Sep 28, 2024 · 24 comments

Comments

@Jordan87
Copy link

Jordan87 commented Sep 28, 2024

For a quite long time start/stop charging, preconditioning and othere features are not working at all.
Im able to do those from android MyPeugeot app.
psacc is updating status if I perform update via MyPeugeot app so there is working connection with PSA server.

Today I even reinstalled psacc addon in HA but still with the same result.

Steps to reproduce the behavior:

  1. i.e. http://homeassistant.local:5000/wakeup/MyVIN
  2. when the bug append ? Over two months ago
  3. Does it persist after restarting the program? Yes
  4. Does it persist after recreate config by going to http://server_address:port/config? Yes

Environment (please complete the following information):

  • OS: HAOS
  • Peugeot 308 Plug-In Hybrid
  • Application version v3.5.3
  • Log from http://server_address:port/log and browser console log

2024-09-28 15:56:10,206 :: INFO :: ask wakeup to MyVIN 2024-09-28 15:56:10,207 :: INFO :: topic: psa/RemoteServices/from/cid/AP-ACNT200003476968/VehCharge/state: {'action': 'state'} 2024-09-28 15:56:10,207 :: ERROR :: Can't refresh remote token, please redo otp procedure Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 157, in _refresh_remote_token self.manager.refresh_token_now() File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/common/utils.py", line 23, in wrapper raise RateLimitException psa_car_controller.common.utils.RateLimitException 2024-09-28 15:56:10,208 :: INFO :: 192.168.1.76 - - [28/Sep/2024 15:56:10] "GET /wakeup/MyVIN HTTP/1.1" 200 - 2024-09-28 15:56:10,247 :: INFO :: 192.168.1.76 - - [28/Sep/2024 15:56:10] "GET /favicon.ico HTTP/1.1" 200 - 2024-09-28 15:56:27,693 :: INFO :: <Request 'http://localhost:5000/charge_control?vin=MyVIN' [GET]> 2024-09-28 15:56:27,694 :: INFO :: save config change 2024-09-28 15:56:27,695 :: INFO :: 172.30.32.1 - - [28/Sep/2024 15:56:27] "GET /charge_control?vin=MyVIN HTTP/1.1" 200 - 2024-09-28 15:56:27,697 :: INFO :: 172.30.32.1 - - [28/Sep/2024 15:56:27] "GET /get_vehicleinfo/MyVIN?from_cache=1 HTTP/1.1" 200 - 2024-09-28 15:56:44,406 :: INFO :: Preconditioning: topic: psa/RemoteServices/from/cid/AP-ACNT200003476968/ThermalPrecond: {'asap': 'activate', 'programs': {'program1': {'day': [0, 0, 0, 0, 0, 0, 0], 'hour': 34, 'minute': 7, 'on': 0}, 'program2': {'day': [0, 0, 0, 0, 0, 0, 0], 'hour': 34, 'minute': 7, 'on': 0}, 'program3': {'day': [0, 0, 0, 0, 0, 0, 0], 'hour': 34, 'minute': 7, 'on': 0}, 'program4': {'day': [0, 0, 0, 0, 0, 0, 0], 'hour': 34, 'minute': 7, 'on': 0}}} 2024-09-28 15:56:44,407 :: ERROR :: Can't refresh remote token, please redo otp procedure Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 157, in _refresh_remote_token self.manager.refresh_token_now() File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/common/utils.py", line 23, in wrapper raise RateLimitException psa_car_controller.common.utils.RateLimitException 2024-09-28 15:56:44,408 :: INFO :: 172.30.32.1 - - [28/Sep/2024 15:56:44] "GET /preconditioning/MyVIN/1 HTTP/1.1" 200 -

@R-dehaan
Copy link

Same issue here

@Jordan87 Jordan87 changed the title "Can't refresh remote token" and "RateLimitException" visible in log and not able to dtart/stop charging or refresh status "Can't refresh remote token" and "RateLimitException" visible in log and not able to start/stop charging or refresh status Oct 1, 2024
@altbla
Copy link

altbla commented Oct 9, 2024

Same here, started about 1.5 months ago..

@weirdo1971
Copy link

weirdo1971 commented Oct 21, 2024

Problem solved with de- and reinstalling PSA_car_controller

@altbla
Copy link

altbla commented Oct 22, 2024

Problem solved with de- and reinstalling PSA_car_controller

Tried it and didnt help, check your logs. It works about half the time, the other half it isnt and you have RateLimit in the log.

@Jordan87
Copy link
Author

I also tried reinstalling whole addon in HA, and right after installation and whole OTP process same issue is present.
Status is updating if I use car or start charging from my charging station, but im not able to start/postpone charge or precondition from psacc

@altbla
Copy link

altbla commented Oct 22, 2024

my guess is Stelantis servers are limiting us, because the addon makes too many connections to them every day. I know the addon uses local cache so it doesnt query the server every few minutes, but it seems like its still too often, maybe Stelantis reduced the daily limit recently?

@weirdo1971
Copy link

Problem solved with de- and reinstalling PSA_car_controller

Tried it and didnt help, check your logs. It works about half the time, the other half it isnt and you have RateLimit in the log.

I did also de- and reinstall the official phone app and let it connect to te car, before reinstalling PSA controller. I checked the logs; no errors en it works fine... I dont know why it works, but it does!

@Jordan87
Copy link
Author

For me no change after removing or reinstalling MyPeugeot app.
Can you try to use i.e. this command if you will see those errors in logs after it?
http://homeassistant.local:5000/wakeup/YourVIN (of course with proper link for HA and your VIN)

@weirdo1971
Copy link

2024-10-23 18:16:51,103 :: INFO :: ask wakeup to My_VIN

2024-10-23 18:16:51,103 :: INFO :: topic: psa/RemoteServices/from/cid/OV-ACNT200008538854/VehCharge/state: {'action': 'state'}

2024-10-23 18:16:51,578 :: INFO :: 10.0.0.252 - - [23/Oct/2024 18:16:51] "GET /wakeup/My_VIN HTTP/1.1" 200 -

2024-10-23 18:16:51,807 :: INFO :: mqtt msg received: psa/RemoteServices/to/cid/OV-ACNT200008538854/VehCharge/state/ProcessManagement b'{"process_date":"2024-10-23T18:16:51Z","vin":"My_VIN","correlation_id":"605c001296584d9188654db8cc23686c20241023181651577","process_code":"900","process_message":"[process.900.request.accepted.key]"}'

2024-10-23 18:16:51,946 :: INFO :: mqtt msg received: psa/RemoteServices/to/cid/OV-ACNT200008538854/VehCharge/state/ProcessManagement b'{"process_date":"2024-10-23T18:16:51Z","vin":"My_VIN","correlation_id":"605c001296584d9188654db8cc23686c20241023181651577","process_code":"901","process_message":"[process.901.vehicle.asleep.key]"}'

2024-10-23 18:16:52,364 :: INFO :: save config change

2024-10-23 18:17:10,236 :: INFO :: mqtt msg received: psa/RemoteServices/to/cid/OV-ACNT200008538854/VehCharge/state/ProcessManagement b'{"process_date":"2024-10-23T18:17:10Z","vin":"My_VIN","correlation_id":"605c001296584d9188654db8cc23686c20241023181651577","process_code":"903","process_message":"[process.903.request.forwarded.to.vehicle.key]"}'

2024-10-23 18:17:10,461 :: INFO :: mqtt msg received: psa/RemoteServices/to/cid/OV-ACNT200008538854/VehCharge/state b'{"resp_date":"2024-10-23T18:17:10Z","vin":"My_VIN","correlation_id":"605c001296584d9188654db8cc23686c20241023181651577","return_code":"0"}'

@Jordan87
Copy link
Author

It seems that it started to work again from last Sunday evenig. No change from my side in psacc or MyPeugeot android app.

I see from time to time "please redo OTP" in logs but it is sporadic and code 401 visible before that error

2024-10-29 01:29:08,149 :: INFO :: save config change
2024-10-29 01:29:09,190 :: INFO :: token expired, renew
2024-10-29 01:29:09,191 :: ERROR :: can't refresh_remote_token: {'httpCode': '401', 'httpMessage': 'Unauthorized', 'moreInformation': 'Cannot pass the security checks that are required by the target API or operation, Enable debug headers for more details.'}
Create a new one
2024-10-29 01:29:10,957 :: INFO :: token expired, renew
2024-10-29 01:29:10,958 :: ERROR :: Can't refresh remote token, please redo otp procedure
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 177, in _refresh_remote_token
self._get_remote_access_token(otp_code)
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 208, in _get_remote_access_token
self.remoteCredentials.access_token = data["access_token"]
KeyError: 'access_token'
2024-10-29 01:29:10,958 :: WARNING :: last request is send again, token was expired

So at least for now we can consider that it is working again for me :)

@Jordan87
Copy link
Author

Today I remembered that I did one more thing over the weekend, I performed system reset in my Peugeot 308 (to factory settings in menu). It was done because my Tomtom traffic services stoped to work (subsription has ended long time ago but it was still working ;) ) and I wanted to check it after reset.
This shouldnt affect psacc but maybe you can try if you have same problems in psacc logs.

@altbla
Copy link

altbla commented Nov 3, 2024

psa_car_controller.common.utils.RateLimitException
2024-11-02 23:19:49,530 :: INFO :: charging status of VR7xxxxxxxxxxxx14 is InProgress, battery level: 13
2024-11-02 23:19:49,531 :: ERROR :: force_update:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/charge_control.py", line 70, in force_update
self.psacc.remote_client.wakeup(self.vin)
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/common/utils.py", line 23, in wrapper
raise RateLimitException
psa_car_controller.common.utils.RateLimitException

i still keep getting these errors, a bunch of times per day.

@libertyx82
Copy link

Also here the same Error, OTP was done twice but no change

2024-11-06 11:22:28,061 :: ERROR :: Can't refresh remote token, please redo otp procedure
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 177, in _refresh_remote_token
self._get_remote_access_token(otp_code)
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 208, in _get_remote_access_token
self.remoteCredentials.access_token = data["access_token"]
KeyError: 'access_token

@jorrevanmunster
Copy link

I got the same issue, which causes the data from the car being out of date. My log:

2024-11-19 12:36:55,854 :: INFO :: charging status of [VIN] is InProgress, battery level: 28
2024-11-19 12:36:55,854 :: ERROR :: force_update:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/charge_control.py", line 70, in force_update
    self.psacc.remote_client.wakeup(self.vin)
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/common/utils.py", line 23, in wrapper
    raise RateLimitException
psa_car_controller.common.utils.RateLimitException

@libertyx82
Copy link

I guess that it is an issue on the API Side, the App does also not working

@Jordan87
Copy link
Author

App for me is working fine but in psacc I see again those errors and all actions from psacc are not working (also status update during charging)

@rexasso
Copy link

rexasso commented Jan 5, 2025

Hi there,
Best wishes!
Same issue since couple of days. Accessing data is ok but remote control for preconditioning or charge fails. Logs still the same "Can't refresh remote token".
I try resinstalling add on in HA, install fix version in HAV from https://github.com/raphaelbarreiros/psacc-ha, create my own CT in proxmox and then setup fresh new docker version. Everytime the same issue in logs.

I have noticed 2 things:

  1. While making the enrollement process and when we have to get the code for oauth2 in the network tab: the request is red and mentionned "canceled": is it normal ? Size is also 0
    image

  2. I looked at Stellantis web side, it looks like they strongly improved security as it is now necessary to enroll app and then generate CSR (SSL certificate). Is it something new ?

Any help is welcome
Thanks

@JaySea77
Copy link

JaySea77 commented Jan 9, 2025

"Can't refresh remote token, please redo otp procedure"
This happens every other couple weeks. After redoing it, it just comes back after a couple weeks again.
How can we make it keep working?

@wjansenw
Copy link

steps I did to solve it:

  • in the app on my phone, I removed all data/cache related to the app
  • logged in in the app on the phone; it asked me to reset the number of linked apps (which was above 20)
  • did try to login via the psa_car_controller which worked, but I was now getting rate_limit exceptions
  • decided to turn off psa_car_controller for an hour, and also remove all data/cache from the app on the phone
  • restarted psa_car_controller, and I now have a working set-up again; can't use the phone app for now, but managing via HA is much easier compared to the phone anyway...

@altbla
Copy link

altbla commented Jan 13, 2025

how long has it been working for you now?
usually it works for a few days and then starts throwing up token errors and rate limit exception..

steps I did to solve it:

  • in the app on my phone, I removed all data/cache related to the app
  • logged in in the app on the phone; it asked me to reset the number of linked apps (which was above 20)
  • did try to login via the psa_car_controller which worked, but I was now getting rate_limit exceptions
  • decided to turn off psa_car_controller for an hour, and also remove all data/cache from the app on the phone
  • restarted psa_car_controller, and I now have a working set-up again; can't use the phone app for now, but managing via HA is much easier compared to the phone anyway...

@rexasso
Copy link

rexasso commented Jan 13, 2025

Hi guys,
Thanks for your response. Just to check but I am afraid we are mixing two topics here :

  1. reaching maximum number of connection / linked apps (above 20)
  2. having only few connections (in my case I have mobile apps on 3 mobile devices + 1 psa controller)

In my case I can still "read info" (battery, mileage,...) but no command accepted.

Do you mean both situation are linked ? Does that mean when my container restart and I have to reconnect I "burn" a token so afer 20 reconnect even with same containrized PSA, i reach the 20 max? Thus how to clean this listed registered apps? What do you mean "It asked me to reset the number of linked apps"?

Other question : when you retrieve token in the "id=XXXXXX&scope" oauth2 logs, do you see that the oauth request is failing in Chrome network logs ?

Thanks

@wjansenw
Copy link

I indeed think they are connected.

I was getting mileage info, battery status, but only in a push-mode. Never in a pull mode. Eg. if the car was charging, I would only get the update when charging started, and when it finished. While the car was driving, i would get regular battery levels and mileage info.
But start/stop of charge and/or preconditioning or getting battery charge levels while charging: no updates - unless I refreshed the battery status in the app on my phone.

I indeed think that if you need to enter the received text message, it burns one of the 20 connected devices.
The only way to reset it, is to remove all data related to the app on the phone and go through the login and reset procedure. And afterwards, reconfigure the container.

Not sure how long it will now continue to work. Will update when it stops.

Regards,

@altbla
Copy link

altbla commented Jan 13, 2025

I for one tried to re-install (also clear app data) a few times, never received the "clear all connected devices".
But i am running the old version of the app, from mid summer, before the update that broke everything.
Will not update, unless this reset connection feature is added in the newest version from october?

@wjansenw
Copy link

No idea - I am running the october version apparently.

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

No branches or pull requests

9 participants