evcc icon indicating copy to clipboard operation
evcc copied to clipboard

Peugeot token expired after evcc restart

Open naymore opened this issue 11 months ago • 32 comments

Describe the bug

I‘m not entirely sure if it‘s a refresh token issue. But it happened multiple times now that I restarted EVCV (in HA) and the Peugeot connection does not work anymore. Right now it was after the update to 0.211

I wouldn‘t mind really if the peugeot „get tokens“ process wouldn‘t be such a PITA (cannot acquire new tokens without my PC).

[main ] INFO 2025/12/07 13:57:52 evcc 0.211.0
[main ] INFO 2025/12/07 13:57:52 using config file: /config/evcc.yaml
[main ] INFO 2025/12/07 13:57:52 using sqlite database: /data/evcc.db
[main ] INFO 2025/12/07 13:57:52 UI listening at :7070
[proxy-5021] DEBUG 2025/12/07 13:57:52 modbus proxy for 192.168.50.9:502 listening at :5021
[main ] ERROR 2025/12/07 13:57:54 creating vehicle car2 failed: cannot create vehicle type 'template': cannot create vehicle type 'peugeot': token expired
[lp-1 ] DEBUG 2025/12/07 13:57:55 charge total import: 416.382kWh
[site ] WARN 2025/12/07 13:57:55 vehicle 'Säbelzahntiger' does not support automatic detection

Steps to reproduce

  1. restart evcc
  2. peugeot connection lost

Configuration details

I can provide it later but I don‘t think it‘s relevant here.

Log details

According to documentation (i will provide it later if necessaey)

What type of operating system or environment does evcc run on?

HomeAssistant Add-on

External automation

  • [x] I have made sure that no external automation like HomeAssistant or Node-RED is active or accessing any of the mentioned devices when this issue occurs.

Nightly build

  • [x] I have verified that the issue is reproducible with the latest nightly build

Version

0.211.0

naymore avatar Dec 07 '25 13:12 naymore

I can only suggest https://github.com/evcc-io/evcc/discussions/23684. If somebody knows more about Peugeot tokens happy to take a PR.

/cc @hurzhurz

andig avatar Dec 07 '25 16:12 andig

I can just say i have the same problem since +-2 weeks... EVCC is always disconnecting from the peugeot cloud. not only on reboot but also after 1 or 2 days just so... The car was not charged in the morning 3 times now...

Madkayne avatar Dec 11 '25 08:12 Madkayne

The car was not charged in the morning 3 times now...

Charging has nothing to do with cloud! See https://github.com/evcc-io/evcc/issues/25874#issuecomment-3640734270 and put pressure on Peugeot! It's your right...

andig avatar Dec 11 '25 08:12 andig

Yes it has, it wasn't charging cause EVCC lost connection to peugeot cloud. I already signed at change.org. No idea how i could put more pressure on peugeot as support wont understand a clue.

Madkayne avatar Dec 11 '25 08:12 Madkayne

I repeat. Charging has nothing to do with cloud. Please stop claiming it has or provide proof.

andig avatar Dec 11 '25 08:12 andig

Jesus is dont go into a discussion here.

Madkayne avatar Dec 11 '25 10:12 Madkayne

No hill I want to die on either ;). But since I've built this stuff you'll need to trust me on this.

On the original issue: we need an http trace log from working token to token refresh and token expired. Just looking at the final error does not help in any way unfortunately. Closing here until available.

/cc @hurzhurz

andig avatar Dec 11 '25 10:12 andig

And to quote from https://github.com/hacf-fr/renault-api/issues/1348#issuecomment-2410666664:

Sadly the Renault API is fully undocumented.

andig avatar Dec 11 '25 11:12 andig

Yes... the whole API authorization process really needs to change (for almost any car manufacturer) but especially for Stellantis/Peugeot (I understand Renault is no role model here either but apart from being also French this is an entirely different car conglomerate).

I'd happy to help with the Stellantis debuggung. Not sure what needs to be done though. Set log levels for site, loadpoint vehicle on verbose and it's all good? I figured I only have a few hours of history. Do I need to send logs to a remote syslog server to be of any help here?

EDIT: Actually I might set debug level to verbose and then restart EVCC (or conduct an update)... that should be pretty revealing.

naymore avatar Dec 15 '25 08:12 naymore

You need vehicle on trace and loadpoint on debug or error to see the errors.

andig avatar Dec 15 '25 09:12 andig

Is it possible that the accesstoken and refreshtoken will not be written back to evcc.yaml when they get renewed instead they are only renewed in memory? so if the application gets restarted old and maybe expired tokens will be used.

cton avatar Dec 17 '25 12:12 cton

https://github.com/evcc-io/evcc/issues/25874#issuecomment-3654597635

andig avatar Dec 17 '25 17:12 andig

Just to chime in: The Stellantis API is just spotty. Their own APP has the same problems:

  • Login
  • Use the app
  • Close the app
  • Do not use the app for a few days
  • Open app and you need to login again

Very frustrating to say the least, but it's not an issue of EVCC only.

bramsmulders avatar Dec 18 '25 14:12 bramsmulders

So as I assumed the token gets refreshed but the accesstoken and the refreshtoken will not be updated in evcc.yaml

cton avatar Dec 18 '25 14:12 cton

Yaml is never written to

andig avatar Dec 18 '25 15:12 andig

So it is the expected behaviour, that after restarting the tokens have to be manually renewed? Is the behaviour the same when switching from yaml to database? Are the tokens stored and renewed in database?

cton avatar Dec 18 '25 15:12 cton

Are the tokens stored and renewed in database?

Yes. Repeating myself once more (and for the last time) https://github.com/evcc-io/evcc/issues/25874#issuecomment-3654597635

andig avatar Dec 18 '25 15:12 andig

@andig maybe it would help if the settings db could be updated via the API. Then one could make something to automate the process of getting and updating of new tokens (e.g. using https://github.com/hurzhurz/psa-token-helper/tree/main/automated). (Though not myself, as I have sold my e-Corsa and have no way to test anymore)

For those who want to try something different to avoid the PSA API, this is the method I used in the end before I sold it: https://github.com/evcc-io/evcc/discussions/13685?sort=new#discussioncomment-13914257 Though it might just work on early electric PSA vehicles (from before the facelift)!

hurzhurz avatar Dec 18 '25 16:12 hurzhurz

Before doing that we need to figure out what‘s wrong here and why this happens.

andig avatar Dec 18 '25 16:12 andig

One time in the past it looked to me like the PSA API was half-broken when EVCC tried to refresh the token: It did consume the old refresh-token but did not return a new one. In such cases, I don't think there can anything be done in EVCC.

Though it is tricky to debug. At other times the trace log, from the time it happend, was already gone until I noticed it.

For a long time, before I switched to EVCC, I used a self-built solution using Node-RED. There I did just a single API query after the vehicle was plugged in to get the start SoC. And I had very rare issues with the tokens. I think the more often you query the API, the higher the chances are you catch a moment when the API has a malfunction...

hurzhurz avatar Dec 18 '25 17:12 hurzhurz