flobz / psa_car_controller

Control psa car with connected_car v4 API.
GNU General Public License v3.0
385 stars 196 forks source link

Cannot get remote refresh token error #851

Closed vineethktpla closed 1 month ago

vineethktpla commented 2 months ago

Error : 2024-04-15 11:02:36,058 :: ERROR :: Can't refresh remote token 'refresh_token' Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 167, in _refresh_remote_token self.remoteCredentials.refresh_token = data["refresh_token"] KeyError: 'refresh_token'

Platform: home assistant.

I tried to redo the authentication with --web-conf and once I did the authentication, I tried to restart the ad-on with -f config.json -c charge_config.json -r parameter gives me this error.

Sometimes, restarting the homeassistant fixes this issue sometimes not.

kasper-coding commented 2 months ago

Same issue here! I run it a separate app.

mj1985 commented 2 months ago

Looks like a PSA Server issue, I also got the message including rate limit exceeded, but I didn't forced updates or something like that. Since a 15 minutes the servers are working fine again.

zazazouthecat commented 2 months ago

Same error too here. Can't auth now

2024-04-16 07:58:34,646 :: INFO :: 
Your vehicles: ["{'vin': 'VRXXXXXXXXXXXXXX', 'vehicle_id': '111b60eb6155acb9971053634c735ec544ae85eb52665b2e1cc60909a7f1979616ad01d7e531038903ac44b41db3cee3738756cb51a493176325fe32d03e19feff5ce9850cf4013eaec48ee2a234f0a9cb69f8f13366a418ac6ba6552', 'label': 'e-208', 'brand': 'Peugeot', 'abrp_name': 'peugeot:e208:20:50', 'battery_power': 46, 'fuel_capacity': 0, 'max_elec_consumption': 70, 'max_fuel_consumption': 0}"]
2024-04-16 07:58:34,647 :: INFO :: save config change
2024-04-16 07:58:34,647 :: INFO :: App version 3.5.0
2024-04-16 07:58:34,649 :: ERROR :: finish_oauth:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/web/view/config_oauth.py", line 56, in finish_oauth
    config_views.INITIAL_SETUP.connect(code)
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/setup/app_decoder.py", line 134, in connect
    app.load_app()
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/car_controller.py", line 102, in load_app
    self.is_good = self.myp.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-04-16 07:58:34,649 :: INFO :: 172.30.32.1 - - [16/Apr/2024 07:58:34] "POST /_dash-update-component HTTP/1.1" 200 -
zazazouthecat commented 2 months ago

more log for debug maybe... Retry new setup connection 12:03

2024-04-16 12:03:16,490 :: INFO :: Initial setup...
2024-04-16 12:03:22,891 :: INFO :: 172.30.32.1 - - [16/Apr/2024 12:03:22] "POST /_dash-update-component HTTP/1.1" 200 -
2024-04-16 12:03:24,881 :: INFO :: 172.30.32.1 - - [16/Apr/2024 12:03:24] "GET /config_connect?url=https://idpcvs.peugeot.com/am/oauth2/authorize?client_id%3D1eebc2d5-5df3-459b-a624-20abfcf82530%26redirect_uri%3Dmymap%253A%252F%252Foauth2redirect%252Ffr%26response_type%3Dcode%26scope%3Dopenid%2520profile%26state%3DoZbpnr6wvgBNktls_0WMOg%26code_challenge%3DfFinxenXcmrtXPpCloW82MtkwDXPbHdyKcnIVk1oDIU%26code_challenge_method%3DS256 HTTP/1.1" 200 -
2024-04-16 12:03:25,069 :: INFO :: 172.30.32.1 - - [16/Apr/2024 12:03:25] "GET /_dash-layout HTTP/1.1" 200 -
2024-04-16 12:03:25,070 :: INFO :: 172.30.32.1 - - [16/Apr/2024 12:03:25] "GET /_dash-dependencies HTTP/1.1" 200 -
2024-04-16 12:03:25,105 :: INFO :: 172.30.32.1 - - [16/Apr/2024 12:03:25] "POST /_dash-update-component HTTP/1.1" 200 -
2024-04-16 12:03:25,138 :: INFO :: 172.30.32.1 - - [16/Apr/2024 12:03:25] "POST /_dash-update-component HTTP/1.1" 204 -
2024-04-16 12:04:00,295 :: ERROR :: Exception on /get_vehicleinfo/VRXXXXXXXXXXXXXX [GET]
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/web/view/api.py", line 48, in get_vehicle_info
    response=json.dumps(APP.myp.get_vehicle_info(vin, from_cache).to_dict(), default=str),
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/psa_client.py", line 107, in get_vehicle_info
    res = self.api().get_vehicle_status(car.vehicle_id)
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/connected_car_api/api/vehicles_api.py", line 1229, in get_vehicle_status
    (data) = self.get_vehicle_status_with_http_info(id, **kwargs)  # noqa: E501
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/connected_car_api/api/vehicles_api.py", line 1293, in get_vehicle_status_with_http_info
    return self.api_client.call_api(
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/oauth.py", line 107, in call_api
    return self._ApiClient__call_api(resource_path, method,
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/connected_car_api/api_client.py", line 147, in __call_api
    self.update_params_for_auth(header_params, query_params, auth_settings)
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/connected_car_api/api_client.py", line 504, in update_params_for_auth
    auth_setting = self.configuration.auth_settings().get(auth)
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/connected_car_api/configuration.py", line 241, in auth_settings
    'value': 'Bearer ' + self.access_token
TypeError: can only concatenate str (not "NoneType") to str
2024-04-16 12:04:00,296 :: INFO :: 172.30.32.1 - - [16/Apr/2024 12:04:00] "GET /get_vehicleinfo/VRXXXXXXXXXXXXXX?from_cache=1 HTTP/1.1" 500 -
2024-04-16 12:04:00,296 :: INFO :: <Request 'http://localhost:5000/charge_control?vin=VRXXXXXXXXXXXXXX' [GET]>
2024-04-16 12:04:00,297 :: INFO :: 172.30.32.1 - - [16/Apr/2024 12:04:00] "GET /charge_control?vin=VRXXXXXXXXXXXXXX HTTP/1.1" 200 -
2024-04-16 12:04:00,301 :: INFO :: 172.30.32.1 - - [16/Apr/2024 12:04:00] "GET /battery/soh/VRXXXXXXXXXXXXXX HTTP/1.1" 200 -
2024-04-16 12:04:09,431 :: INFO :: save config change
2024-04-16 12:04:09,798 :: INFO :: 
Your vehicles: ["{'vin': 'VRXXXXXXXXXXXXXX', 'vehicle_id': '111eb6155acb9971053634c7351544ae85eb52665b2e1cc69a7f1979616ad01d7e531038ed903ac44b41db3cee8756cb51a493176325fe32d09fefff5ce9850cf4013eaec4f8ee2a234f0b69f8f13366a418ac6ba326552', 'label': 'e-208', 'brand': 'Peugeot', 'abrp_name': 'peugeot:e208:20:50', 'battery_power': 46, 'fuel_capacity': 0, 'max_elec_consumption': 70, 'max_fuel_consumption': 0}"]
2024-04-16 12:04:09,799 :: INFO :: save config change
2024-04-16 12:04:09,799 :: INFO :: App version 3.5.0
2024-04-16 12:04:10,445 :: INFO :: ["{'vin': 'VRXXXXXXXXXXXXXX', 'vehicle_id': '111eb6155acb9971053634c7351544ae85eb52665b2e1cc69a7f1979616ad01d7e531038ed903ac44b41db3cee8756cb51a493176325fe32d09fefff5ce9850cf4013eaec4f8ee2a234f0b69f8f13366a418ac6ba326552', 'label': 'e-208', 'brand': 'Peugeot', 'abrp_name': 'peugeot:e208:20:50', 'battery_power': 46, 'fuel_capacity': 0, 'max_elec_consumption': 70, 'max_fuel_consumption': 0}"]
2024-04-16 12:04:10,773 :: ERROR :: remote_refresh_token isn't defined
2024-04-16 12:04:11,170 :: ERROR :: Error during activation: {'err': 'NOK:FORBIDDEN'}
2024-04-16 12:04:11,429 :: ERROR :: Can't refresh remote token 'access_token'
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 174, 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 206, in _get_remote_access_token
    self.remoteCredentials.access_token = data["access_token"]
KeyError: 'access_token'
2024-04-16 12:04:15,597 :: INFO :: save config change
vineethktpla commented 2 months ago

After multiple retries I managed to run the ad-on, but this is what happens when i try to wakeup using rest command

2024-04-16 13:26:15,920 :: INFO :: ask wakeup to VR3UKZKXmmmmm
2024-04-16 13:26:15,922 :: INFO :: topic: psa/RemoteServices/from/cid/AP-ACNT200008710854/VehCharge/state: {'action': 'state'}
2024-04-16 13:26:16,995 :: ERROR :: Can't refresh remote token 'refresh_token'
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 167, in _refresh_remote_token
    self.remoteCredentials.refresh_token = data["refresh_token"]
KeyError: 'refresh_token'
2024-04-16 13:26:34,655 :: INFO :: save config change

After this the adon crashed. Issue persists after restart of home assistant. did redo the authentication, but still not able to start the ad-on without multiple retries. Issue started from yesterday

GewoonJaap commented 2 months ago

Also experiencing the same issue since this weekend. It retrieves data just fine, but I am unable to start the pre-condtioning or do a wakeup call for example. Getting the same errors as everyone else ^^

charging status of VIN is InProgress, battery level: 31
2024-04-16 15:49:02,106 :: 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
ask wakeup to VIN
2024-04-16 15:37:02,185 :: INFO :: topic: psa/RemoteServices/from/cid/AP-XXXXXX/VehCharge/state: {'action': 'state'}
2024-04-16 15:37:02,185 :: ERROR :: Can't refresh remote token 
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 155, 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

I also tried to re-authenticate this weekend, when entering the GUID from the oauth redirect, the loading bar kept spinning forever after clicking the Submit button in the webapp

vineethktpla commented 2 months ago

Screenshot_20240416-165017

Now control shows this.

And all my entities in HA is unavailable now !!

Please someone help me fix this

ikbensuper commented 2 months ago

I Also have the exact same issue: 2024-04-16 17:21:47,641 :: ERROR :: Error during activation: {'newversion': None, 'newversionurl': None, 'err': 'NOK:MAXNBTOOLS'} 2024-04-16 17:21:48,332 :: ERROR :: remote_refresh_token isn't defined 2024-04-16 17:21:48,771 :: ERROR :: Error during activation: {'err': 'NOK:FORBIDDEN'} 2024-04-16 17:21:50,406 :: ERROR :: Can't refresh remote token 'access_token' Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 174, 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 206, in _get_remote_access_token self.remoteCredentials.access_token = data["access_token"] KeyError: 'access_token'

Started with the info not being available in Home Assistant. Restarted the docker container. And saw the token wasn't valid anymore. When trying to Re-activat.. The above error occurs

vineethktpla commented 2 months ago

I Also have the exact same issue: 2024-04-16 17:21:47,641 :: ERROR :: Error during activation: {'newversion': None, 'newversionurl': None, 'err': 'NOK:MAXNBTOOLS'} 2024-04-16 17:21:48,332 :: ERROR :: remote_refresh_token isn't defined 2024-04-16 17:21:48,771 :: ERROR :: Error during activation: {'err': 'NOK:FORBIDDEN'} 2024-04-16 17:21:50,406 :: ERROR :: Can't refresh remote token 'access_token' Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 174, 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 206, in _get_remote_access_token self.remoteCredentials.access_token = data["access_token"] KeyError: 'access_token'

Started with the info not being available in Home Assistant. Restarted the docker container. And saw the token wasn't valid anymore. When trying to Re-activat.. The above error occurs

Since you are getting {'err': 'NOK:FORBIDDEN'} error, I think you exceeded the limit of sms activations set by the psa server. To fix this, install mypeugeot app from the play/apple store ( uninstall and reinstall if already installed ), login then try to turn on the climate control. The app now ask you to reset your pin and send sms. once you do this, this error will be fixed.

This is explained here https://github.com/flobz/psa_car_controller/blob/master/FAQ.md#2-error-during-activation-newversion-200-newversionurl-httpminwebocom-err-nokforbidden

vineethktpla commented 2 months ago

Datas are retrieving now after multple reinstallations and tries but no remote commands are working

2024-04-17 10:12:37,847 :: INFO :: Preconditioning: topic: psa/RemoteServices/from/cid/AP-ACNT20000871xxx4/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-04-17 10:12:38,652 :: ERROR :: Can't refresh remote token 'refresh_token'
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 167, in _refresh_remote_token
    self.remoteCredentials.refresh_token = data["refresh_token"]
KeyError: 'refresh_token'
2024-04-17 10:12:56,886 :: INFO :: save config change

This is what happens with a climate control call

weirdo1971 commented 2 months ago

same issue with app (docker) and /or HA add-on

2024-04-17 11:14:30,858 :: WARNING :: Disconnected with result code 1 2024-04-17 11:14:31,354 :: ERROR :: Can't refresh remote token 'refresh_token' Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 167, in _refresh_remote_token self.remoteCredentials.refresh_token = data["refresh_token"] KeyError: 'refresh_token' 2024-04-17 11:14:32,192 :: INFO :: save config change

jwolansk commented 2 months ago

Peugeot app is also unable to retrieve current data, so it looks like the PSA server issues. But the psacc app could certainly do better when handling the error, by not crashing 🙂

vineethktpla commented 2 months ago

Screenshot_20240417-133643

Official app also cannot do the preconditioning but other datas are updating properly

mj1985 commented 2 months ago

The myOpel App is working fine, including precondition, data sync of SOC etc.

mdkeil commented 2 months ago

same issue with app (docker) and /or HA add-on

2024-04-17 11:14:30,858 :: WARNING :: Disconnected with result code 1 2024-04-17 11:14:31,354 :: ERROR :: Can't refresh remote token 'refresh_token' Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 167, in _refresh_remote_token self.remoteCredentials.refresh_token = data["refresh_token"] KeyError: 'refresh_token' 2024-04-17 11:14:32,192 :: INFO :: save config change

+1 same to me I think for two days..

JaySea77 commented 2 months ago

Can't refresh token anymore and no commands work. Has been like this for a couple of days. Otp config not responding either.

jwolansk commented 2 months ago

I think, MyPeugeot app hit the same rate limit exception as psacc in my case.

vineethktpla commented 2 months ago

I can now confirm that my peugeot app works just fine from today morning. I can refresh soc while charging, and it updates properly. Climate control also works fine. But same issue with psacc unfortunately. No luck so far with remote commands like wake up or climate control or stop/start charge

christophe-heidet commented 2 months ago

I have exactly the same issue with each remote command to a e208 with this common result:

 Create a new one
2024-04-18 09:11:18,022 :: ERROR :: Can't refresh remote token 
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 173, in _refresh_remote_token
    otp_code = self.get_otp_code()
  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
vineethktpla commented 2 months ago

Update again: Mypeugeot app stopped responding again !! Such dumb servers !!

maximumstruggle commented 2 months ago

Had the same issue yesterday :

It looks like the same behaviour from a few weeks ago. I wonder if the SoC update is working during a DC charge, could be interesting to know

sod75 commented 2 months ago

Just want to add just in case. I was seeing the error couple days ago as well but it has gone away since yesterday... I still received position, SOC data, etc throughout.

I just tried preconditioning and that triggers the Refresh token error.

2024-04-18 21:12:32,563 :: INFO :: Preconditioning: topic: psa/RemoteServices/from/cid/AP-ACNT200008553362/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-04-18 21:12:33,244 :: ERROR :: can't refresh_remote_token: {'error_description': 'grant is invalid', 'error': 'invalid_grant'}
 Create a new one
2024-04-18 21:12:35,093 :: INFO :: save config change
GewoonJaap commented 2 months ago

Just want to add just in case. I was seeing the error couple days ago as well but it has gone away since yesterday... I still received position, SOC data, etc throughout.

I just tried preconditioning and that triggers the Refresh token error.

2024-04-18 21:12:32,563 :: INFO :: Preconditioning: topic: psa/RemoteServices/from/cid/AP-ACNT200008553362/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-04-18 21:12:33,244 :: ERROR :: can't refresh_remote_token: {'error_description': 'grant is invalid', 'error': 'invalid_grant'}
 Create a new one
2024-04-18 21:12:35,093 :: INFO :: save config change

Data is indeed still being received but all actions from this app to the Peugeot servers are giving the token error

vineethktpla commented 2 months ago

I still get the data as well. It updates odometer, battery level and everything during trip and other times. The issue is we cannot manually force a remote command like precondition or wakeup call which will give this error. The battery level is not updating during charging. I have to manually go to car and unlock it to get the data in the app. So obviously charge control won't work.

fre4242 commented 2 months ago

I have the same 'can't refresh_remote_token' problem. But also the myOpel smartphone app isn't able to wakeup and get more actual values. It presents old values when forcing to refresh.

vineethktpla commented 2 months ago

MyPeugeot app works now, but still issue persists with psacc ![Uploading Screenshot_20240419-145447~2.png…]()

Waxolunist commented 2 months ago

Now my battery is at 100% and I will sit here till tomorrow on it. This is frustrating.

christophe-heidet commented 2 months ago

Could it be related to this topic : https://github.com/flobz/psa_car_controller/discussions/700 ?

Waxolunist commented 2 months ago

If the app is working but the controller is not, that could be the reason.

mj1985 commented 2 months ago

The App is "working", pull down to update on the charging page isn't working. Changing the precondition and sync it, is working in the app, sometimes the app updates the charging status after all and updates it every 20 minutes and after charging is finished. But definitely not smooth like a week before

vineethktpla commented 2 months ago

Will there be any way around or workaround for this frustrating problem?

@flobz ??

Waxolunist commented 2 months ago

I get an update when I stop charging every ten minutes on my charging station. Not a good solution, but a workaround.

vineethktpla commented 2 months ago

Waxolunist

With DC charging, its possible that car updates soc every now and then, but with AC charging remote commands like stop charging is not working for me at the moment so not a good workaround for me. I have to manually walk to the car and wake it up to update the datas while charging, which indeed defeats the whole purpose of having an app/controller

mj1985 commented 2 months ago

@vineethktpla Try to program a precondition schedule in the App, the car is syncing the data after it. It's workaround for me (using AC).

bobmorane06 commented 2 months ago

This is the most frustrating piece of garbage ever (Peugeot, not flobz' API SW). Limiting the charge to 80% must have worked 3 times since I got my new 208 a few weeks ago. Now even from within the MyPeugeot app, data refresh fails. I think I'm going to setup a relay / switch controlled by home assistant and manually set the time based on current charge and give up on psa_car_controller.

I get an update when I stop charging every ten minutes on my charging station. Not a good solution, but a workaround. @Waxolunist, can you clarify? How do you stop charging, by shutting off the power to the AC charger? Or by running http://localhost:5000/charge_now/YOURVIN/0 ?

RiderCrazy commented 2 months ago

This is the most frustrating piece of garbage ever (Peugeot, not flobz' API SW). Limiting the charge to 80% must have worked 3 times since I got my new 208 a few weeks ago. Now even from within the MyPeugeot app, data refresh fails. I think I'm going to setup a relay / switch controlled by home assistant and manually set the time based on current charge and give up on psa_car_controller.

That's what I'm going to do too... since my 6 months free subscription is over and it's 80€/year and not reliable :/

bobmorane06 commented 2 months ago

I had forgotten about the 80€. I'll change the settings in the car to not share my data with PSA anymore, might as well not let them spy on me and make money out of reselling my data.

vineethktpla commented 2 months ago

@vineethktpla Try to program a precondition schedule in the App, the car is syncing the data after it. It's workaround for me (using AC).

Works well, but everytime i need to send a new schedule to make it update

mj1985 commented 2 months ago

@vineethktpla Try to program a precondition schedule in the App, the car is syncing the data after it. It's workaround for me (using AC).

Works well, but everytime i need to send a new schedule to make it update

I'm using one schedule and de/activate it, you don't need to create a new schedule everytime.

maximumstruggle commented 2 months ago

I have sleep issues, I wake up every two hours so now I stop it myself from the Peugeot app when I wake up and I know the thresold is near

Waxolunist commented 2 months ago

@bobmorane06 My wallbox is an e-go. I stop the charging via the e-go Api. Not via the Peugeot app. So my python program runs in batch every ten minutes. If the charge is below 80% and the car is connected I stop and start the charging. Then the battery level gets updated in the psacc.

wech71 commented 2 months ago

It seems to me that the response to the request to refresh the token, may previously have contained the current or new refresh token, but now it doesn't

When running with --debug, the data json only contains the new access_token, but no refresh_token:

psacc_1  | 2024-04-23 06:05:53,529 :: DEBUG :: {"access_token":"55****-****-****-********1e81","refresh_token":"2f*****5-7***-****-****-***********4","scope":"openid profile","id_token":"ey***.***.***","token_type":"Bearer","expires_in":3599}
psacc_1  | 2024-04-23 06:05:53,537 :: DEBUG :: _bearer_request on post - https://api.groupe-psa.com/connectedcar/v4/virtualkey/remoteaccess/token?client_id=07******-****-****-****-6b*********c
psacc_1  | 2024-04-23 06:05:53,830 :: DEBUG :: refresh_remote_token: {'access_token': 'af******-****-****-a***-************', 'scope': 'psaCustomerId psaMqttService', 'token_type': 'Bearer', 'expires_in': 899}
psacc_1  | 2024-04-23 06:05:53,831 :: ERROR :: Can't refresh remote token 'refresh_token'
psacc_1  | Traceback (most recent call last):
psacc_1  |   File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 167, in _refresh_remote_token
psacc_1  |     self.remoteCredentials.refresh_token = data["refresh_token"]
psacc_1  | KeyError: 'refresh_token'
               res = self.manager.post(REMOTE_URL + self.account_info.client_id,
                                        json={"grant_type": "refresh_token",
                                              "refresh_token": self.remoteCredentials.refresh_token},
                                        headers=self.headers)
                data = res.json()
                logger.debug("refresh_remote_token: %s", data)
                if "access_token" in data:
                    self.remoteCredentials.access_token = data["access_token"]
                    self.remoteCredentials.refresh_token = data["refresh_token"]   <<< line 167
                    bad_remote_token = False

I guess the refresh token should only be read from data when it exists in the "data" hash.

edit 1: At least the MQTT updates seem to work without problems - as the refresh_token access is the last statement and the exception is being catched below, I guess it just works, and it is more like kind of a warning than a real problem.

gerar19 commented 2 months ago

same problems here :(

vineethktpla commented 2 months ago

It seems to me that the response to the request to refresh the token, may previously have contained the current or new refresh token, but now it doesn't

When running with --debug, the data json only contains the new access_token, but no refresh_token:

psacc_1  | 2024-04-23 06:05:53,529 :: DEBUG :: {"access_token":"55****-****-****-********1e81","refresh_token":"2f*****5-7***-****-****-***********4","scope":"openid profile","id_token":"ey***.***.***","token_type":"Bearer","expires_in":3599}
psacc_1  | 2024-04-23 06:05:53,537 :: DEBUG :: _bearer_request on post - https://api.groupe-psa.com/connectedcar/v4/virtualkey/remoteaccess/token?client_id=07******-****-****-****-6b*********c
psacc_1  | 2024-04-23 06:05:53,830 :: DEBUG :: refresh_remote_token: {'access_token': 'af******-****-****-a***-************', 'scope': 'psaCustomerId psaMqttService', 'token_type': 'Bearer', 'expires_in': 899}
psacc_1  | 2024-04-23 06:05:53,831 :: ERROR :: Can't refresh remote token 'refresh_token'
psacc_1  | Traceback (most recent call last):
psacc_1  |   File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 167, in _refresh_remote_token
psacc_1  |     self.remoteCredentials.refresh_token = data["refresh_token"]
psacc_1  | KeyError: 'refresh_token'
               res = self.manager.post(REMOTE_URL + self.account_info.client_id,
                                        json={"grant_type": "refresh_token",
                                              "refresh_token": self.remoteCredentials.refresh_token},
                                        headers=self.headers)
                data = res.json()
                logger.debug("refresh_remote_token: %s", data)
                if "access_token" in data:
                    self.remoteCredentials.access_token = data["access_token"]
                    self.remoteCredentials.refresh_token = data["refresh_token"]   <<< line 167
                    bad_remote_token = False

I guess the refresh token should only be read from data when it exists in the "data" hash.

edit 1: At least the MQTT updates seem to work without problems - as the refresh_token access is the last statement and the exception is being catched below, I guess it just works, and it is more like kind of a warning than a real problem.

The very first MQTT updates seems to be working fine. but after that this issue of refresh token


2024-04-22 14:18:30,665 :: INFO :: save config change
2024-04-22 14:19:15,437 :: ERROR :: Can't configure MQTT Client
2024-04-22 14:19:15,765 :: ERROR :: remote_refresh_token isn't defined
2024-04-22 14:19:16,757 :: INFO :: save config change
2024-04-22 14:19:16,885 :: INFO :: ask wakeup to VRxxxxxxxxxxxxxxx
2024-04-22 14:19:16,887 :: INFO :: topic: psa/RemoteServices/from/cid/AP-ACNTxxxxxxxxxxxxxxx/VehCharge/state: {'action': 'state'}
2024-04-22 14:19:16,895 :: INFO :: 172.30.32.1 - - [22/Apr/2024 14:19:16] "POST /_dash-update-component HTTP/1.1" 200 -
2024-04-22 14:19:17,011 :: INFO :: Connected with result code {'session present': 0}
2024-04-22 14:19:17,013 :: INFO :: subscribe to psa/RemoteServices/to/cid/AP-ACNTxxxxxxxxxxxxxxx/#
2024-04-22 14:19:17,014 :: INFO :: subscribe to psa/RemoteServices/events/MPHRTServices/VRxxxxxxxxxxxxxxx
2024-04-22 14:19:17,215 :: INFO :: mqtt msg received: psa/RemoteServices/to/cid/AP-ACNTxxxxxxxxxxxxxxx/VehCharge/state/ProcessManagement b'{"process_date":"2024-04-22T12:19:17Z","vin":"VRxxxxxxxxxxxxxxx","correlation_id":"ba5c6f11ed684679befa41b050c064cf20240422121916888","process_code":"900","process_message":"[process.900.request.accepted.key]"}'
2024-04-22 14:19:17,346 :: INFO :: mqtt msg received: psa/RemoteServices/to/cid/AP-ACNTxxxxxxxxxxxxxxx/VehCharge/state/ProcessManagement b'{"process_date":"2024-04-22T12:19:17Z","vin":"VRxxxxxxxxxxxxxxx","correlation_id":"ba5c6f11ed684679befa41b050c064cf20240422121916888","process_code":"901","process_message":"[process.901.vehicle.asleep.key]"}'
2024-04-22 14:19:20,134 :: INFO :: 172.30.32.1 - - [22/Apr/2024 14:19:20] "GET /config_otp HTTP/1.1" 200 -
2024-04-22 14:19:20,247 :: INFO :: 172.30.32.1 - - [22/Apr/2024 14:19:20] "GET /_dash-layout HTTP/1.1" 200 -
2024-04-22 14:19:20,300 :: INFO :: 172.30.32.1 - - [22/Apr/2024 14:19:20] "GET /_dash-dependencies HTTP/1.1" 200 -
2024-04-22 14:19:20,404 :: INFO :: 172.30.32.1 - - [22/Apr/2024 14:19:20] "POST /_dash-update-component HTTP/1.1" 200 -
2024-04-22 14:19:20,731 :: INFO :: 172.30.32.1 - - [22/Apr/2024 14:19:20] "POST /_dash-update-component HTTP/1.1" 200 -
2024-04-22 14:19:20,736 :: INFO :: 172.30.32.1 - - [22/Apr/2024 14:19:20] "POST /_dash-update-component HTTP/1.1" 204 -
2024-04-22 14:19:20,781 :: INFO :: 172.30.32.1 - - [22/Apr/2024 14:19:20] "POST /_dash-update-component HTTP/1.1" 204 -
2024-04-22 14:19:22,379 :: INFO :: 172.30.32.1 - - [22/Apr/2024 14:19:22] "POST /_dash-update-component HTTP/1.1" 200 -
2024-04-22 14:19:33,105 :: INFO :: 172.30.32.1 - - [22/Apr/2024 14:19:33] "GET /vehicles/trips HTTP/1.1" 200 -
2024-04-22 14:19:33,218 :: INFO :: 172.30.32.1 - - [22/Apr/2024 14:19:33] "GET /vehicles/chargings HTTP/1.1" 200 -
2024-04-22 14:19:34,561 :: INFO :: mqtt msg received: psa/RemoteServices/events/MPHRTServices/VRxxxxxxxxxxxxxxx b'{"date":"2024-04-22T10:56:51Z","etat_res_elec":0,"precond_state":{"available":1,"programs":{"program1":{"hour":9,"minute":0,"on":0,"day":[1,0,0,0,0,0,0]},"program2":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program3":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program4":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]}},"asap":0,"status":0,"aff":1},"charging_state":{"program":{"hour":0,"minute":0},"available":1,"remaining_time":0,"rate":6,"cable_detected":0,"soc_batt":79,"autonomy_zev":226,"type":1,"aff":1,"hmi_state":3,"mode":0},"stolen_state":0,"vin":"VRxxxxxxxxxxxxxxx","reason":0,"signal_quality":5,"sev_stop_date":"2024-04-22T07:14:14Z","fds":["NXC01","NXO01","NXP01","NCG01","NXM01","NXJ01","NXE01","NXD01","NXR01","NAS01","NDR01","NXL01","NXK01","NXW01","NAE01","NXT01","NBM01","NXQ01","NXG01","NXH01","NXA01","NXN01","NXU01","NAO01"],"sev_state":0,"obj_counter":1,"privacy_customer":0,"privacy_applicable":0,"privacy_applicable_max":1,"superlock_state":0}'
2024-04-22 14:19:34,563 :: ERROR :: on_mqtt_message:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 95, in _fix_not_updated_api
if car and car.status.get_energy('Electric').charging.status != INPROGRESS:
AttributeError: 'NoneType' object has no attribute 'get_energy'
2024-04-22 14:19:34,574 :: INFO :: mqtt msg received: psa/RemoteServices/events/MPHRTServices/VRxxxxxxxxxxxxxxx b'{"date":"2024-04-22T10:56:52Z","etat_res_elec":0,"precond_state":{"available":1,"programs":{"program1":{"hour":9,"minute":0,"on":0,"day":[1,0,0,0,0,0,0]},"program2":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program3":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program4":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]}},"asap":0,"status":0,"aff":1},"charging_state":{"program":{"hour":0,"minute":0},"available":1,"remaining_time":0,"rate":6,"cable_detected":0,"soc_batt":79,"autonomy_zev":226,"type":1,"aff":1,"hmi_state":3,"mode":0},"stolen_state":0,"vin":"VRxxxxxxxxxxxxxxx","reason":3,"signal_quality":5,"sev_stop_date":"2024-04-22T07:14:14Z","fds":["NXC01","NXO01","NXP01","NCG01","NXM01","NXJ01","NXE01","NXD01","NXR01","NAS01","NDR01","NXL01","NXK01","NXW01","NAE01","NXT01","NBM01","NXQ01","NXG01","NXH01","NXA01","NXN01","NXU01","NAO01"],"sev_state":0,"obj_counter":2,"privacy_customer":0,"privacy_applicable":0,"privacy_applicable_max":1,"superlock_state":0}'
2024-04-22 14:19:34,575 :: ERROR :: on_mqtt_message:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 95, in _fix_not_updated_api
if car and car.status.get_energy('Electric').charging.status != INPROGRESS:
AttributeError: 'NoneType' object has no attribute 'get_energy'
2024-04-22 14:19:34,599 :: INFO :: mqtt msg received: psa/RemoteServices/events/MPHRTServices/VRxxxxxxxxxxxxxxx b'{"date":"2024-04-22T10:56:52Z","etat_res_elec":0,"precond_state":{"available":1,"programs":{"program1":{"hour":9,"minute":0,"on":0,"day":[1,0,0,0,0,0,0]},"program2":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program3":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program4":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]}},"asap":0,"status":0,"aff":1},"charging_state":{"program":{"hour":0,"minute":0},"available":1,"remaining_time":0,"rate":6,"cable_detected":0,"soc_batt":79,"autonomy_zev":226,"type":1,"aff":1,"hmi_state":3,"mode":0},"stolen_state":0,"vin":"VRxxxxxxxxxxxxxxx","reason":4,"signal_quality":5,"sev_stop_date":"2024-04-22T07:14:14Z","fds":["NXC01","NXO01","NXP01","NCG01","NXM01","NXJ01","NXE01","NXD01","NXR01","NAS01","NDR01","NXL01","NXK01","NXW01","NAE01","NXT01","NBM01","NXQ01","NXG01","NXH01","NXA01","NXN01","NXU01","NAO01"],"sev_state":0,"obj_counter":3,"privacy_customer":0,"privacy_applicable":0,"privacy_applicable_max":1,"superlock_state":0}'
2024-04-22 14:19:34,600 :: ERROR :: on_mqtt_message:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 95, in _fix_not_updated_api
if car and car.status.get_energy('Electric').charging.status != INPROGRESS:
AttributeError: 'NoneType' object has no attribute 'get_energy'
2024-04-22 14:19:34,612 :: INFO :: mqtt msg received: psa/RemoteServices/events/MPHRTServices/VRxxxxxxxxxxxxxxx b'{"date":"2024-04-22T10:56:53Z","etat_res_elec":0,"precond_state":{"available":1,"programs":{"program1":{"hour":9,"minute":0,"on":0,"day":[1,0,0,0,0,0,0]},"program2":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program3":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program4":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]}},"asap":0,"status":0,"aff":1},"charging_state":{"program":{"hour":0,"minute":0},"available":1,"remaining_time":0,"rate":6,"cable_detected":0,"soc_batt":79,"autonomy_zev":226,"type":1,"aff":1,"hmi_state":3,"mode":0},"stolen_state":0,"vin":"VRxxxxxxxxxxxxxxx","reason":4,"signal_quality":5,"sev_stop_date":"2024-04-22T07:14:14Z","fds":["NXC01","NXO01","NXP01","NCG01","NXM01","NXJ01","NXE01","NXD01","NXR01","NAS01","NDR01","NXL01","NXK01","NXW01","NAE01","NXT01","NBM01","NXQ01","NXG01","NXH01","NXA01","NXN01","NXU01","NAO01"],"sev_state":0,"obj_counter":4,"privacy_customer":0,"privacy_applicable":0,"privacy_applicable_max":1,"superlock_state":0}'
2024-04-22 14:19:34,613 :: ERROR :: on_mqtt_message:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 95, in _fix_not_updated_api
if car and car.status.get_energy('Electric').charging.status != INPROGRESS:
AttributeError: 'NoneType' object has no attribute 'get_energy'
2024-04-22 14:19:34,625 :: INFO :: mqtt msg received: psa/RemoteServices/events/MPHRTServices/VRxxxxxxxxxxxxxxx b'{"date":"2024-04-22T10:56:54Z","etat_res_elec":0,"precond_state":{"available":1,"programs":{"program1":{"hour":9,"minute":0,"on":0,"day":[1,0,0,0,0,0,0]},"program2":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program3":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program4":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]}},"asap":0,"status":0,"aff":1},"charging_state":{"program":{"hour":0,"minute":0},"available":1,"remaining_time":0,"rate":0,"cable_detected":0,"soc_batt":79,"autonomy_zev":226,"type":1,"aff":1,"hmi_state":1,"mode":0},"stolen_state":0,"vin":"VRxxxxxxxxxxxxxxx","reason":4,"signal_quality":5,"sev_stop_date":"2024-04-22T07:14:14Z","fds":["NXC01","NXO01","NXP01","NCG01","NXM01","NXJ01","NXE01","NXD01","NXR01","NAS01","NDR01","NXL01","NXK01","NXW01","NAE01","NXT01","NBM01","NXQ01","NXG01","NXH01","NXA01","NXN01","NXU01","NAO01"],"sev_state":0,"obj_counter":5,"privacy_customer":0,"privacy_applicable":0,"privacy_applicable_max":1,"superlock_state":0}'
2024-04-22 14:19:34,638 :: INFO :: mqtt msg received: psa/RemoteServices/events/MPHRTServices/VRxxxxxxxxxxxxxxx b'{"date":"2024-04-22T10:56:55Z","etat_res_elec":0,"precond_state":{"available":1,"programs":{"program1":{"hour":9,"minute":0,"on":0,"day":[1,0,0,0,0,0,0]},"program2":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program3":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program4":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]}},"asap":0,"status":0,"aff":1},"charging_state":{"program":{"hour":0,"minute":0},"available":1,"remaining_time":0,"rate":0,"cable_detected":1,"soc_batt":79,"autonomy_zev":226,"type":1,"aff":1,"hmi_state":3,"mode":2},"stolen_state":0,"vin":"VRxxxxxxxxxxxxxxx","reason":4,"signal_quality":5,"sev_stop_date":"2024-04-22T07:14:14Z","fds":["NXC01","NXO01","NXP01","NCG01","NXM01","NXJ01","NXE01","NXD01","NXR01","NAS01","NDR01","NXL01","NXK01","NXW01","NAE01","NXT01","NBM01","NXQ01","NXG01","NXH01","NXA01","NXN01","NXU01","NAO01"],"sev_state":0,"obj_counter":6,"privacy_customer":0,"privacy_applicable":0,"privacy_applicable_max":1,"superlock_state":0}'
2024-04-22 14:19:34,664 :: INFO :: mqtt msg received: psa/RemoteServices/events/MPHRTServices/VRxxxxxxxxxxxxxxx b'{"date":"2024-04-22T10:56:57Z","etat_res_elec":0,"precond_state":{"available":1,"programs":{"program1":{"hour":9,"minute":0,"on":0,"day":[1,0,0,0,0,0,0]},"program2":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program3":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program4":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]}},"asap":0,"status":0,"aff":1},"charging_state":{"program":{"hour":0,"minute":0},"available":1,"remaining_time":635,"rate":0,"cable_detected":1,"soc_batt":79,"autonomy_zev":226,"type":0,"aff":1,"hmi_state":0,"mode":2},"stolen_state":0,"vin":"VRxxxxxxxxxxxxxxx","reason":4,"signal_quality":5,"sev_stop_date":"2024-04-22T07:14:14Z","fds":["NXC01","NXO01","NXP01","NCG01","NXM01","NXJ01","NXE01","NXD01","NXR01","NAS01","NDR01","NXL01","NXK01","NXW01","NAE01","NXT01","NBM01","NXQ01","NXG01","NXH01","NXA01","NXN01","NXU01","NAO01"],"sev_state":0,"obj_counter":7,"privacy_customer":0,"privacy_applicable":0,"privacy_applicable_max":1,"superlock_state":0}'
2024-04-22 14:19:34,666 :: ERROR :: on_mqtt_message:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 95, in _fix_not_updated_api
if car and car.status.get_energy('Electric').charging.status != INPROGRESS:
AttributeError: 'NoneType' object has no attribute 'get_energy'
2024-04-22 14:19:34,668 :: INFO :: mqtt msg received: psa/RemoteServices/to/cid/AP-ACNTxxxxxxxxxxxxxxx/VehCharge/state/ProcessManagement b'{"process_date":"2024-04-22T12:19:34Z","vin":"VRxxxxxxxxxxxxxxx","correlation_id":"ba5c6f11ed684679befa41b050c064cf20240422121916888","process_code":"903","process_message":"[process.903.request.forwarded.to.vehicle.key]"}'
2024-04-22 14:19:34,677 :: INFO :: mqtt msg received: psa/RemoteServices/events/MPHRTServices/VRxxxxxxxxxxxxxxx b'{"date":"2024-04-22T12:19:28Z","etat_res_elec":0,"precond_state":{"available":1,"programs":{"program1":{"hour":9,"minute":0,"on":0,"day":[1,0,0,0,0,0,0]},"program2":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program3":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program4":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]}},"asap":0,"status":0,"aff":1},"charging_state":{"program":{"hour":0,"minute":0},"available":1,"remaining_time":635,"rate":0,"cable_detected":1,"soc_batt":79,"autonomy_zev":226,"type":0,"aff":1,"hmi_state":0,"mode":2},"stolen_state":0,"vin":"VRxxxxxxxxxxxxxxx","reason":0,"signal_quality":5,"sev_stop_date":"2024-04-22T07:14:14Z","fds":["NXC01","NXO01","NXP01","NCG01","NXM01","NXJ01","NXE01","NXD01","NXR01","NAS01","NDR01","NXL01","NXK01","NXW01","NAE01","NXT01","NBM01","NXQ01","NXG01","NXH01","NXA01","NXN01","NXU01","NAO01"],"sev_state":0,"obj_counter":1,"privacy_customer":0,"privacy_applicable":0,"privacy_applicable_max":1,"superlock_state":0}'
2024-04-22 14:19:34,678 :: ERROR :: on_mqtt_message:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 95, in _fix_not_updated_api
if car and car.status.get_energy('Electric').charging.status != INPROGRESS:
AttributeError: 'NoneType' object has no attribute 'get_energy'
2024-04-22 14:19:34,702 :: INFO :: mqtt msg received: psa/RemoteServices/events/MPHRTServices/VRxxxxxxxxxxxxxxx b'{"date":"2024-04-22T12:19:30Z","etat_res_elec":0,"precond_state":{"available":1,"programs":{"program1":{"hour":9,"minute":0,"on":0,"day":[1,0,0,0,0,0,0]},"program2":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program3":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program4":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]}},"asap":0,"status":0,"aff":1},"charging_state":{"program":{"hour":0,"minute":0},"available":1,"remaining_time":635,"rate":0,"cable_detected":1,"soc_batt":79,"autonomy_zev":226,"type":0,"aff":1,"hmi_state":0,"mode":2},"stolen_state":0,"vin":"VRxxxxxxxxxxxxxxx","reason":3,"signal_quality":5,"sev_stop_date":"2024-04-22T07:14:14Z","fds":["NXC01","NXO01","NXP01","NCG01","NXM01","NXJ01","NXE01","NXD01","NXR01","NAS01","NDR01","NXL01","NXK01","NXW01","NAE01","NXT01","NBM01","NXQ01","NXG01","NXH01","NXA01","NXN01","NXU01","NAO01"],"sev_state":0,"obj_counter":2,"privacy_customer":0,"privacy_applicable":0,"privacy_applicable_max":1,"superlock_state":0}'
2024-04-22 14:19:34,703 :: ERROR :: on_mqtt_message:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 95, in _fix_not_updated_api
if car and car.status.get_energy('Electric').charging.status != INPROGRESS:
AttributeError: 'NoneType' object has no attribute 'get_energy'
2024-04-22 14:19:34,715 :: INFO :: mqtt msg received: psa/RemoteServices/events/MPHRTServices/VRxxxxxxxxxxxxxxx b'{"date":"2024-04-22T12:19:31Z","etat_res_elec":0,"precond_state":{"available":1,"programs":{"program1":{"hour":9,"minute":0,"on":0,"day":[1,0,0,0,0,0,0]},"program2":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program3":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program4":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]}},"asap":0,"status":0,"aff":1},"charging_state":{"program":{"hour":0,"minute":0},"available":1,"remaining_time":635,"rate":0,"cable_detected":1,"soc_batt":79,"autonomy_zev":226,"type":0,"aff":1,"hmi_state":0,"mode":2},"stolen_state":0,"vin":"VRxxxxxxxxxxxxxxx","reason":4,"signal_quality":5,"sev_stop_date":"2024-04-22T07:14:14Z","fds":["NXC01","NXO01","NXP01","NCG01","NXM01","NXJ01","NXE01","NXD01","NXR01","NAS01","NDR01","NXL01","NXK01","NXW01","NAE01","NXT01","NBM01","NXQ01","NXG01","NXH01","NXA01","NXN01","NXU01","NAO01"],"sev_state":0,"obj_counter":3,"privacy_customer":0,"privacy_applicable":0,"privacy_applicable_max":1,"superlock_state":0}'
2024-04-22 14:19:34,717 :: ERROR :: on_mqtt_message:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 95, in _fix_not_updated_api
if car and car.status.get_energy('Electric').charging.status != INPROGRESS:
AttributeError: 'NoneType' object has no attribute 'get_energy'
2024-04-22 14:19:34,939 :: INFO :: mqtt msg received: psa/RemoteServices/to/cid/AP-ACNTxxxxxxxxxxxxxxx/VehCharge/state b'{"resp_date":"2024-04-22T12:19:34Z","vin":"VRxxxxxxxxxxxxxxx","correlation_id":"ba5c6f11ed684679befa41b050c064cf20240422121916888","return_code":"0"}'
2024-04-22 14:19:37,971 :: INFO :: mqtt msg received: psa/RemoteServices/events/MPHRTServices/VRxxxxxxxxxxxxxxx b'{"date":"2024-04-22T12:19:37Z","etat_res_elec":0,"precond_state":{"available":1,"programs":{"program1":{"hour":9,"minute":0,"on":0,"day":[1,0,0,0,0,0,0]},"program2":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program3":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]},"program4":{"hour":34,"minute":7,"on":0,"day":[0,0,0,0,0,0,0]}},"asap":0,"status":0,"aff":1},"charging_state":{"program":{"hour":0,"minute":0},"available":1,"remaining_time":635,"rate":0,"cable_detected":1,"soc_batt":79,"autonomy_zev":226,"type":0,"aff":1,"hmi_state":0,"mode":2},"stolen_state":0,"vin":"VRxxxxxxxxxxxxxxx","reason":4,"signal_quality":5,"sev_stop_date":"2024-04-22T07:14:14Z","fds":["NXC01","NXO01","NXP01","NCG01","NXM01","NXJ01","NXE01","NXD01","NXR01","NAS01","NDR01","NXL01","NXK01","NXW01","NAE01","NXT01","NBM01","NXQ01","NXG01","NXH01","NXA01","NXN01","NXU01","NAO01"],"sev_state":0,"obj_counter":4,"privacy_customer":0,"privacy_applicable":0,"privacy_applicable_max":1,"superlock_state":0}'
2024-04-22 14:19:37,973 :: ERROR :: on_mqtt_message:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/RemoteClient.py", line 95, in _fix_not_updated_api
if car and car.status.get_energy('Electric').charging.status != INPROGRESS:
AttributeError: 'NoneType' object has no attribute 'get_energy'
2024-04-22 14:19:43,921 :: WARNING :: Disconnected with result code 0
2024-04-22 14:19:43,922 :: WARNING :: No error.
GewoonJaap commented 2 months ago

So the app still functions without the refresh token field in the api? But what would happen when the access token expires? Because thats when we need the refresh token right?

vineethktpla commented 2 months ago

Issue is with the remote refresh token I think. But it's a frustrating problem and Remote commands works. I guess psacc code needs to be modified to fetch the refresh token from the response same way the official app does. Mypeugeot app works fine now for remote commands

mj1985 commented 2 months ago

The myOpel App is kinda working, no charge update on pull-down or every 10 minutes while charging. But I do get an update after charging is finished ( I setup my own automation in HA). Precondition and data sync is working fine.

JaySea77 commented 2 months ago

So the app still functions without the refresh token field in the api? But what would happen when the access token expires? Because thats when we need the refresh token right?

What do you mean the app still functions? You can't send any command successfully. Yes you can see updates if some other app triggers them, but that doesn't make the app 'work'.

GewoonJaap commented 2 months ago

Issue is with the remote refresh token I think. But it's a frustrating problem and Remote commands works. I guess psacc code needs to be modified to fetch the refresh token from the response same way the official app does. Mypeugeot app works fine now for remote commands

Ah okay, its great to hear the commands work tho. I guess we have to take a look at the reponses to get the refresh token in a new way so it works like before?

vineethktpla commented 2 months ago

Issue is with the remote refresh token I think. But it's a frustrating problem and Remote commands works. I guess psacc code needs to be modified to fetch the refresh token from the response same way the official app does. Mypeugeot app works fine now for remote commands

Ah okay, its great to hear the commands work tho. I guess we have to take a look at the reponses to get the refresh token in a new way so it works like before?

I mean it only works with official app now. Psacc is not working