Integration of Polestar 2

We got a brand new 2025 Polestar 2 last week, and unfortunately we have not been able to add it to the Polestar integration. We are always getting “API unexpected failure” I have tried uninstalling and re-installing about 5 times, I’ve tried different accounts (mine as an Admin, and my wife’s as Owner and Admin) Not sure where to go now

It seems that the API gives an error for the moment.
It worked fine till yesterday, since this morning the integration throws up an error, and when trying to reconfigure it gives the same error you got: ‘API unexpected failure’.

This error originated from a custom integration.

Logger: custom_components.polestar_api.config_flow
Source: custom_components/polestar_api/config_flow.py:47
integration: Polestar API (documentation, issues)
First occurred: 2:57:24 PM (2 occurrences)
Last logged: 2:59:20 PM

Unexpected error creating device
Traceback (most recent call last):
  File "/config/custom_components/polestar_api/config_flow.py", line 47, in _create_device
    await device.async_init()
  File "/config/custom_components/polestar_api/polestar.py", line 143, in async_init
    await self.polestar_api.async_init()
  File "/config/custom_components/polestar_api/pypolestar/polestar.py", line 61, in async_init
    await self.auth.get_token()
  File "/config/custom_components/polestar_api/pypolestar/auth.py", line 85, in get_token
    if (code := await self._get_code()) is None:
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/polestar_api/pypolestar/auth.py", line 140, in _get_code
    if resumePath is None:
       ^^^^^^^^^^
UnboundLocalError: cannot access local variable 'resumePath' where it is not associated with a value
1 Like

I reloaded the integration just now and it fails.
looks like it’s a general issue.

1 Like

hmm, I deleted the integration and the HACS repository, restarted HA and now the Polestar repository doesn’t show up for download anymore?

Thanks for the confirmation. I’ve been trying a few times every day to get it to work, same error every time.

Hey guys, I found a way to programatically lock / unlock my car purely through API but could use some other people’s help to further work it out into a perfect API. Feel free to add me on Discord to discuss further: littlebladed

2 Likes

is this working for you now? I still have the same error too :frowning:

Hi, no it’s still failing I’m sorry to report.

it seems to be a global issue due to changes @ Polestar, but the github page talks about a possible fix, I will give it a try and report back.

it’s working, a fix is coming soon.

1 Like

I’m still getting an error on 1.11.0, it’s complaining no cars found in account. I’ve tried both the main owners account (my wife) or my admin account for the car. Both log in OK to the test URL.

2024-12-11 13:34:32.413 ERROR (MainThread) [custom_components.polestar_api.pypolestar.polestar] No cars found in account
2024-12-11 13:34:32.413 ERROR (MainThread) [custom_components.polestar_api.config_flow] Unexpected error creating device
File “/config/custom_components/polestar_api/config_flow.py”, line 47, in _create_device
File “/config/custom_components/polestar_api/polestar.py”, line 243, in async_init
await self.polestar_api.async_init()
File “/config/custom_components/polestar_api/pypolestar/polestar.py”, line 73, in async_init
File “/config/custom_components/polestar_api/pypolestar/polestar.py”, line 275, in _get_vehicle_data
raise PolestarNoDataException(“No cars found in account”)
custom_components.polestar_api.pypolestar.exception.PolestarNoDataException: No cars found in account

1.11.0 has fixed the problem for me. :smile:

Somewhere in the past after an update all entities were copied, so now I have 2 devices and all entities double. The old ones are unavailable. I cannot find a way to delete these, other then to completely reinstall this integration, correct?

Edit: I read that this issue has been mentioned here before.

OK, after many many attempts, the Polestar 2 integration is working great for me now. Thanks to all!

1 Like