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 · 16 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)

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

6 participants