evcc icon indicating copy to clipboard operation
evcc copied to clipboard

Problem with 2 Hyundais in one EVCC

Open country1706 opened this issue 1 month ago β€’ 9 comments

Description

Hi folks. I have two Hyundais. One Inster and one Ioniq 5. The Inster ist buildt 2025 and the Ioniq 5 is buildt in 2022. Both I have in my config with the vin, that evcc knows which one is on my wallbox. Now I have the issue, that either when I change the car, evcc thinks it's a guest. Even if I tell it which car it is, it tells me, it cannot find it with the token. I'm in Germany, so I tried to change the token just into the password. Because this also didn't work, I changed it back to the token, always with both cars. My Evcc is directly inside my Home Assistant OS and both are at the newest version. Every time I have to save the configuration with the car, which is on the wallbox at this time, again, so it gets the connect to bluelink again. This works as long as I don't change the car.' With the change of the car, the issue starts again. I doesn't matter if I change from the Inster to the Ioniq 5 or the other way. Every time get the same error.

I didn't put the cars into the yaml, I made it with the UI configuration.

Steps to Reproduce

Please take a look in my logs, which I provide here: From Ioniq 5 to Inster: [lp-1 ] ERROR 2026/10/12 14:46:58 charger soc: Get "https://prd.eu-ccapi.hyundai.com:8080/api/v1/spa/vehicles/3691af36-ce19-4237-9385-740cca419ab3/status/latest": ccs token exchange failed: unexpected status: 401 (Unauthorized) POST https://cci-api-eu.hyundai.com/domain/api/v1/auth/token-exchange?serviceType=CCS [lp-1 ] ERROR 2026/10/12 14:46:58 vehicle range: Get "https://prd.eu-ccapi.hyundai.com:8080/api/v1/spa/vehicles/3691af36-ce19-4237-9385-740cca419ab3/status/latest": ccs token exchange failed: unexpected status: 401 (Unauthorized) POST https://cci-api-eu.hyundai.com/domain/api/v1/auth/token-exchange?serviceType=CCS

From Inster to Ioniq 5 [lp-1 ] ERROR 2026/10/13 15:28:10 charger soc: Get "https://prd.eu-ccapi.hyundai.com:8080/api/v1/spa/vehicles/03f3e386-f913-4011-bf8f-345a3f705d7a/status/latest": ccs token exchange failed: unexpected status: 401 (Unauthorized) POST https://cci-api-eu.hyundai.com/domain/api/v1/auth/token-exchange?serviceType=CCS [lp-1 ] ERROR 2026/10/13 15:28:10 vehicle range: Get "https://prd.eu-ccapi.hyundai.com:8080/api/v1/spa/vehicles/03f3e386-f913-4011-bf8f-345a3f705d7a/status/latest": ccs token exchange failed: unexpected status: 401 (Unauthorized) POST https://cci-api-eu.hyundai.com/domain/api/v1/auth/token-exchange?serviceType=CCS

⚠️ RETURN TO EVCC TAB β†’ COPY STEP 2 β†’ PASTE HERE

Configuration (UI)

{
  "charger": [
    {"id":15,"name":"db:15","type":"template","config":{"template":"etrel","host":"192.168.2.163","port":"502"},"deviceProduct":"Sonnen sonnenCharger"}
  ],
  "country": "",
  "currency": "EUR",
  "eebus": {"config":{"certificate":{"private":"***","public":"-----BEGIN CERTIFICATE-----
MIIBvDCCAWOgAwIBAgIRAqyTaEKGE1XcT+Q3ZNEEGSowCgYIKoZIzj0EAwIwPjEL
MAkGA1UEBhMCREUxDTALBgNVBAoTBEVWQ0MxCTAHBgNVBAsTADEVMBMGA1UEAwwM
RVZDQ19IRU1TXzAxMB4XDTI2MDIyODEzMjE0MloXDTM2MDIyNjEzMjE0MlowPjEL
MAkGA1UEBhMCREUxDTALBgNVBAoTBEVWQ0MxCTAHBgNVBAsTADEVMBMGA1UEAwwM
RVZDQ19IRU1TXzAxMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuSnzK5Pd0HfQ
obIFdg6eTZL3V2pWE+pNBHIsPnN1yHNLRoAZbjMuXLol65DmIUi8i2o7P1v4zssI
jB+FP0wT0aNCMEAwDgYDVR0PAQH/BAQDAgeAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
VR0OBBYEFO4q32L0ycAjh6qsfCHM513UM/bJMAoGCCqGSM49BAMCA0cAMEQCIGXL
9gzFVAcwL90pM0I6tbZSF9wOyWBxWuq/z1fSia7bAiBFu7UAHeT1luZ9G+bFeR08
X5SPGz9O5Z/4FLoCrDmx1Q==
-----END CERTIFICATE-----
"},"port":4712,"shipid":"EVCC-6531363165366562"},"status":{"qr":"SHIP;SKI:ee2adf62f4c9c02387aaac7c21cce75dd433f6c9;ID:EVCC-6531363165366562;BRAND:EVCC;TYPE:EnergyManagementSystem;MODEL:HEMS;SERIAL:EVCC-6531363165366562;CAT:2;FPH256:003469928D984830D0ADC7C0D47C38820DE522992EB48C88449F3DDBFAE91131;SPSEC:6B4FE16579D0D53799C285BAF5FC4547;ENDSHIP;","ski":"ee2adf62f4c9c02387aaac7c21cce75dd433f6c9"}},
  "experimental": true,
  "gridExportLimit": 0,
  "influx": {"database":"evcc","insecure":false,"org":"","password":"","token":"","url":"http://192.168.XXX.XXX:8428","user":""},
  "interval": 30,
  "loadpoints": [
    {"id":12,"name":"db:12","alwaysCharge":"off","batteryBoostLimit":100,"charger":"db:15","defaultMode":"smart","limitEnergy":0,"limitSoc":0,"maxCurrent":16,"minCurrent":6,"minSoc":0,"phasesConfigured":3,"planEnergy":0,"planPrecondition":0,"planStrategy":{"continuous":false,"precondition":0},"planTime":"0001-01-01T00:00:00Z","priority":0,"smartCostLimit":0.36,"smartFeedInPriorityLimit":null,"soc":{"estimate":true,"poll":{"interval":3600000000000,"mode":"charging"}},"solarShare":0.9,"thresholds":{"disable":{"delay":180000000000,"threshold":0},"enable":{"delay":60000000000,"threshold":0}},"title":"Wallbox","ui":{"maxTemp":0,"minTemp":0}}
  ],
  "messenger": [
    {"id":14,"name":"db:14","type":"template","config":{"template":"homeassistant","critical":"false","notify":"notify.mobile_app_pixel_10_pro_xl","uri":"***"},"deviceProduct":"Home Assistant"}
  ],
  "meter": [
    {"id":9,"name":"db:9","type":"template","config":{"template":"sonnenbatterie","defaultmode":"self-consumption","host":"192.168.2.91","maxchargepower":"3300","port":"8080","usage":"pv"},"deviceProduct":"Sonnen sonnenBatterie","deviceTitle":"PV-Anlage"},
    {"id":13,"name":"db:13","type":"template","config":{"template":"sonnenbatterie","defaultmode":"self-consumption","host":"192.168.2.91","maxchargepower":"3300","port":"8080","usage":"grid"},"deviceProduct":"Sonnen sonnenBatterie"},
    {"id":8,"name":"db:8","type":"template","config":{"template":"sonnenbatterie","capacity":10,"defaultmode":"self-consumption","host":"192.168.2.91","maxchargepower":"3300","maxsoc":100,"minsoc":20,"port":"8080","token":"***","usage":"battery"},"deviceProduct":"Sonnen sonnenBatterie","deviceTitle":"SonnenBatterie"}
  ],
  "mqtt": {"broker":"","caCert":"","clientCert":"","clientID":"","clientKey":"","insecure":false,"password":"","topic":"evcc","user":""},
  "ocpp": {"config":{"port":8887},"status":{"stations":[]}},
  "ocppforwarder": {"config":[],"status":[]},
  "optimizer": true,
  "optimizerChargingStrategy": "charge_before_export",
  "remote": {"enabled":true},
  "residualPower": 0,
  "shm": {"deviceId":"","deviceSerial":"","vendorId":""},
  "site": {"aux":null,"battery":["db:8"],"consumer":null,"curtail":null,"ext":null,"grid":"db:13","pv":["db:9"],"title":"EVCC Hausenergie"},
  "tariff": [
    {"id":16,"name":"db:16","type":"template","config":{"template":"fixed","price":0.095},"deviceProduct":"Fester Preis"},
    {"id":22,"name":"db:22","type":"template","config":{"template":"energypriceforecast-co2","horizon":"120","region":"DE"},"deviceProduct":"Energy Price Forecast EU COβ‚‚"},
    {"id":21,"name":"db:21","type":"custom","config":{"yaml":"## dynamic price (Ostrom via HAOS)
# price: # current price
#  source: http
#  uri: *****
#  headers:
#    - Content-Type: application/json
#    - Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhZTMxMWIzMDczMzA0NDM0OWI5M2I5ZGQzZWRmYmJiZSIsImlhdCI6MTc4NDI2NDcwNCwiZXhwIjoyMDk5NjI0NzA0fQ.j6G52axw-HEfrNwIcNZyjLBsO1ubF96TutZrhgWWZpk
#  jq: .state | tonumber

## forecast (hourly price forecast)
forecast: # hourly price forecast
  source: http
  uri: *****
  headers:
    - Content-Type: application/json
    - Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI3MzQ2ODRiNjIyMzI0Y2JmYjhjZmFiMWMxOGM0N2NkMiIsImlhdCI6MTc4NDI2NzcyNywiZXhwIjoyMDk5NjI3NzI3fQ.3F6LD_beS5kzmBgomPdHpXfNpNWJFE7Cm7M2tlMLsDs
  jq: |
    .attributes.prices
    | to_entries
    | sort_by(.key)
    | map({
        start: .key,
        end: (
          .key
          | strptime(\"%Y-%m-%dT%H:%M:%S%z\")
          | mktime
          | . + 3600
          | strftime(\"%Y-%m-%dT%H:%M:%S%z\")
          | .[0:-2] + \":\" + .[-2:]
        ),
        value: .value
      })
    | tostring"}},
    {"id":26,"name":"db:26","type":"template","config":{"template":"open-meteo","ac":"1000","alphatemp":"-0.004","az":55,"de":"0","dec":35,"dm":"0","efficiency":"100","interval":"1h","kwp":4.2,"lat":"***","lon":"***","model":"best_match","rossmodel":"0.0342"},"deviceProduct":"Open-Meteo","deviceTitle":"PV-Produktion West"},
    {"id":25,"name":"db:25","type":"template","config":{"template":"open-meteo","ac":"1000","alphatemp":"-0.004","az":-125,"de":"0","dec":35,"dm":"0","efficiency":"100","interval":"1h","kwp":4.5,"lat":"***","lon":"***","model":"best_match","rossmodel":"0.0342"},"deviceProduct":"Open-Meteo","deviceTitle":"PV-Produktion Ost"}
  ],
  "tariffRefs": {"co2":"db:22","feedIn":"db:16","grid":"db:21","planner":"","solar":["db:25","db:26"],"temperature":""},
  "vehicle": [
    {"id":27,"name":"db:27","type":"template","config":{"template":"hyundai","autodetectdisabled":false,"cache":"15m","capacity":77.4,"climaterdisabled":false,"icon":"car","language":"de","password":"***","priority":0,"region":"Europe","title":"Ioniq 5","user":"***","vin":"***","wakeupdisabled":false}},
    {"id":28,"name":"db:28","type":"template","config":{"template":"hyundai","autodetectdisabled":false,"cache":"15m","capacity":42,"climaterdisabled":false,"icon":"car","language":"de","password":"***","priority":0,"region":"Europe","title":"Inster","user":"***","vin":"***","wakeupdisabled":false},"deviceProduct":"Hyundai Bluelink"}
  ]
}

Logs

[lp-1  ] DEBUG 2026/10/13 15:29:45 pv charge current: min 6A > 0.375A (3881W @ 3p, battery: true)
[site  ] DEBUG 2026/10/13 15:29:45 optimizer: home slots updated with measured 217Wh: [141 142 173 155] -> [217 198 195 170]
[site  ] DEBUG 2026/10/13 15:29:45 solar scale P50 over 30 days = 0.878
[site  ] DEBUG 2026/10/13 15:30:15 ----
[lp-1  ] DEBUG 2026/10/13 15:30:15 charge power: 3840W
[lp-1  ] DEBUG 2026/10/13 15:30:15 charge currents: [5.86 5.76 5.89]A
[site  ] DEBUG 2026/10/13 15:30:15 grid power: 9W
[site  ] DEBUG 2026/10/13 15:30:15 battery 1 power: 3867W
[site  ] DEBUG 2026/10/13 15:30:15 battery 1 soc: 80%
[site  ] DEBUG 2026/10/13 15:30:15 pv 1 power: 687W
[site  ] DEBUG 2026/10/13 15:30:15 site power: 3876W
[lp-1  ] DEBUG 2026/10/13 15:30:15 vehicle odometer: 48140km
[lp-1  ] DEBUG 2026/10/13 15:30:15 detected active phases: 3p
[lp-1  ] DEBUG 2026/10/13 15:30:15 session energy: 0.043kWh
[lp-1  ] DEBUG 2026/10/13 15:30:15 charger status: C
[lp-1  ] DEBUG 2026/10/13 15:30:15 vehicle soc: 37%
[lp-1  ] DEBUG 2026/10/13 15:30:15 vehicle soc limit: 100%
[lp-1  ] DEBUG 2026/10/13 15:30:15 vehicle range: 140km
[lp-1  ] DEBUG 2026/10/13 15:30:15 soc estimated: 37.05% (vehicle: 37.00%)
[lp-1  ] DEBUG 2026/10/13 15:30:15 vehicle soc (estimator): 37%
[lp-1  ] DEBUG 2026/10/13 15:30:15 !! plan: plan time zero
[lp-1  ] DEBUG 2026/10/13 15:30:15 pv charge current: 0.383A = 6A + -5.62A (3876W @ 3p)
[lp-1  ] DEBUG 2026/10/13 15:30:15 projected site power 3876W >= 414W disable threshold
[lp-1  ] DEBUG 2026/10/13 15:30:15 pv disable timer start: 3m0s
[lp-1  ] DEBUG 2026/10/13 15:30:15 pv disable in 3m0s

Version

v0.317.1

System

linux/amd64, CEST +02:00

country1706 avatar Oct 13 '26 13:10 country1706

Thanks for the detailed report. The 401 comes from the CCS token exchange step of the EU OneApp/CCI login (vehicle/bluelink/cci.go, exchangeCCSToken), so the CCI token set evcc holds for that vehicle is rejected by Hyundai.

One thing worth checking: the CCI token set is persisted per brand and Bluelink user (bluelink-cci.<brand>.<user>, see settingsKey()), but each vehicle keeps its own in-memory copy. If both cars are registered under the same Bluelink account, the two vehicles share one persisted token set and may invalidate each other's refresh token. That would match "works until I switch the car". This is a hypothesis only, it can't be confirmed from the report.

To narrow it down, could you tell us:

  • Are the Ioniq 5 and the Inster registered under the same Bluelink account (same user), or two different accounts?
  • Is password a real account password or a refresh_token for each car?
  • A log with trace enabled for the vehicle (log: trace or levels: vehicle: trace) covering a car switch, including the cci: lines (e.g. "using persisted token", "refreshing token", "refreshing persisted token failed"). The log you posted only shows normal debug output of the working car.

πŸ€– Generated with Claude Code

github-actions[bot] avatar Oct 13 '26 13:10 github-actions[bot]

To narrow it down, could you tell us:

* Are the Ioniq 5 and the Inster registered under the same Bluelink account (same user), or two different accounts?

* Is `password` a real account password or a `refresh_token` for each car?

* A log with trace enabled for the vehicle (`log: trace` or `levels: vehicle: trace`) covering a car switch, including the `cci:` lines (e.g. "using persisted token", "refreshing token", "refreshing persisted token failed"). The log you posted only shows normal debug output of the working car.

πŸ€– Generated with Claude Code

Both cars are registered under on account. For now, I use the token for both cars. I generate my tokens with the Bluelink token generator inside my Home Assistant. For the last one, I have to unplug the car, with is plugged right now (if you really need it) and plug in the other car. Every time, I refresh the car in the webinterface of evcc, the old log is gone, and it shows me a log without any errors, because I saved the other car and it worked for that time.

country1706 avatar Oct 13 '26 13:10 country1706

Thanks for the answers. Both cars sharing one Bluelink account matches the hypothesis. In vehicle/bluelink/cci.go both vehicles read and write the same persisted key (bluelink-cci.<brand>.<user>), but each Identity keeps its own in-memory bundle. A refresh rotates the CCI refresh tokens, and the other vehicle's in-memory copy goes stale. Its next refresh or CCS exchange would then send tokens Hyundai has already invalidated, which would give the 401 in exchangeCCSToken. This is still unconfirmed without a trace log.

Open points:

  • Please share a trace log (levels: vehicle: trace) of a failing car switch, including the cci: lines ("using persisted token", "refreshing token", "refreshing persisted token failed").
  • Does the password field contain the refresh token from the Home Assistant generator, or your account password? Only a real password triggers the login flow that this code persists.

If the shared-state theory holds, the likely fix is to reload or share the persisted bundle per account instead of per vehicle.

πŸ€– Generated with Claude Code

github-actions[bot] avatar Oct 13 '26 13:10 github-actions[bot]

So, if I get it right, I should use my password in the evcc webfrontend? This had the same effect, last time I tried.

country1706 avatar Oct 13 '26 13:10 country1706

Answering your question: yes, for the EU region please enter your real Bluelink account password in both vehicles (not the token from the Home Assistant generator). Only the password triggers the CCI login whose token set evcc persists, and the 401 comes from that flow (exchangeCCSToken in vehicle/bluelink/cci.go). Please also remove the token from both vehicles so nothing stale is left over.

Why two cars on one account can break each other: both vehicles use the same persisted key (bluelink-cci.<brand>.<user>, settingsKey()), but refreshCCI works on the in-memory v.bundle of each vehicle and never reloads the persisted one. When one car refreshes, Hyundai rotates the refresh tokens, and the other car's in-memory copy becomes invalid. Its next refresh then fails with this 401. This fits "works until the car is switched" but is not confirmed yet.

To confirm, please:

  • Switch both vehicles to the password, save, and tell us whether the error still happens after a car switch.
  • If it does, post a trace log (levels: vehicle: trace) covering the switch, including the cci: lines ("using persisted token", "refreshing token", "refreshing persisted token failed"). You don't need to unplug anything: the log from startup until the first error is enough. In the UI the log can be downloaded from the log view, it is not cleared by saving a vehicle.

If confirmed, the fix would be to reload the persisted bundle before refreshing (or share it per account).

πŸ€– Generated with Claude Code

github-actions[bot] avatar Oct 13 '26 14:10 github-actions[bot]

Ok, I changed both cars into the password, and we'll see the next time I change the car. Thanks for now Claude AI ;-)

country1706 avatar Oct 13 '26 14:10 country1706

Thanks, that works. Nothing more to analyze until the next car switch. If the 401 comes back, please post the trace log (levels: vehicle: trace) from startup to the first error, including the cci: lines. If it no longer happens with the password on both cars, please report that too.

πŸ€– Generated with Claude Code

github-actions[bot] avatar Oct 13 '26 14:10 github-actions[bot]

Closing: using password authentication on both vehicles resolved the 401, as confirmed above. Please reopen with a trace log if it comes back on the next vehicle switch.

πŸ€– Generated with Claude Code

andig avatar Oct 17 '26 13:10 andig

I’m seeing exactly this with an INSTER and an IONIQ 5 on the same Bluelink account, both configured with the real account password (EU, evcc 0.319.0, YAML config, vin set on both). So switching to password did not fix it for me, I think the shared-token hypothesis above is correct.

On every restart both vehicles refresh the shared persisted CCI token in the same second; the second refresh gets 400 because the refresh token was already rotated, and the password fallback then fails as well:

[main  ] INFO  2026/11/14 20:08:21 evcc 0.319.0
[hyundai] DEBUG 2026/11/14 20:08:22 cci: refreshing token
[hyundai] DEBUG 2026/11/14 20:08:22 cci: refreshing token
[hyundai] WARN  2026/11/14 20:08:22 cci: refreshing persisted token failed: cci token refresh failed: unexpected status: 400 (Bad Request) POST https://cci-api-eu.hyundai.com/auth/v2/token-refresh
[hyundai] DEBUG 2026/11/14 20:08:22 cci: logging in via OneApp/CCI password login
[main  ] ERROR 2026/11/14 20:08:22 creating vehicle ioniq5 failed: ... login failed: unexpected redirect after signin: https://idpconnect-eu.hyundai.com/auth/api/v2/user/oauth2/authorize?...
[hyundai] DEBUG 2026/11/14 20:08:22 cci: refresh successful
[site  ] INFO  2026/11/14 20:08:23     vehicle 1: range βœ“ status βœ“ climate βœ“ wakeup βœ“
[site  ] INFO  2026/11/14 20:08:23     vehicle 2: range βœ— status βœ— climate βœ— wakeup βœ—

A restart a few minutes later works for both (β€œusing persisted token” twice, no refresh). During runtime, after the next token rotation, the other vehicle starts failing with ccs token exchange failed: 401 (Unauthorized) on every poll (here ~16 h after start) and is shown as guest when connected.

Suggested fix: share one CCI Identity/token bundle per brand+user across vehicles (or guard refresh with a per-user lock and re-read the persisted bundle before refreshing).

Trace log (levels: vehicle: trace) of the next runtime failure will follow.

domwuk avatar Nov 14 '26 19:11 domwuk