pypolestar / polestar_api

Polestar API - Home Assistant Component
MIT License
137 stars 26 forks source link

Can not have two parallel Polestar IDs anymore #182

Open magnushacker opened 22 hours ago

magnushacker commented 22 hours ago

I have two cars and two separate polestar IDs. Until 1.7.2 this worked fine but in 1.7.3 the second car is no longer available.

image

image

I can see that the integration can successfully authenticate with the first entry (tried to anonymize the logs a bit):

2024-10-24 16:25:02.083 DEBUG (MainThread) [custom_components.polestar_api] async_setup_entry: <ConfigEntry entry_id=79a8864e79aa908b1b02d47ca4cb1dff version=1 domain=polestar_api title=Magnus Polestar state=ConfigEntryState.SETUP_IN_PROGRESS unique_id=None>
<....>
2024-10-24 16:25:03.401 DEBUG (MainThread) [custom_components.polestar_api.pypolestar.auth] {'data': {'getAuthToken': {'id_token': None, 'access_token': 'eyJhbGciOiJSUzI1NiIsImtpZCI6IlVVdkRibjM5QkZkcklhUWR0ZXhFVHdfYkxEa19SUzI1NiIsInBpLmF0bSI6ImwifQ.eyJzY29wZSI6IiIsImNsa
<......>
2024-10-24 16:25:05.053 DEBUG (MainThread) [custom_components.polestar_api.pypolestar.polestar] {'data': {'getConsumerCarsV2': [{'vin': 'XXX', 'internalVehicleIdentifier': XXX, 'salesType': '82B', 'currentPlannedDeliveryDate': '2021-05-27', 'market': 'SE', 'originalMarket': 'SE', 'pno34': 'XXX', 'modelYear': '2021', 'registrationNo': 'TBA97R', 

but then it seems to reuse the same authentication for the second car and of course gets the same API response back:

2024-10-24 16:25:10.963 DEBUG (MainThread) [custom_components.polestar_api] async_setup_entry: <ConfigEntry entry_id=90f0c8caa13aa5f0c56c2bcd2f2392ba version=1 domain=polestar_api title=Emma Polestar state=ConfigEntryState.SETUP_IN_PROGRESS unique_id=None>
<....>
2024-10-24 16:25:11.480 DEBUG (MainThread) [custom_components.polestar_api.pypolestar.auth] {'data': {'getAuthToken': {'id_token': None, 'access_token': 'eyJhbGciOiJSUzI1NiIsImtpZCI6IlVVdkRibjM5QkZkcklhUWR0ZXhFVHdfYkxEa19SUzI1NiIsInBpLmF0bSI6ImwifQ.eyJzY29wZSI6IiIsImNsa
<......>
2024-10-24 16:25:12.473 DEBUG (MainThread) [custom_components.polestar_api.pypolestar.polestar] {'data': {'getConsumerCarsV2': [{'vin': 'XXX', 'internalVehicleIdentifier': XXX', 'salesType': '82B', 'currentPlannedDeliveryDate': '2021-05-27', 'market': 'SE', 'originalMarket': 'SE', 'pno34': 'XXX', 'modelYear': '2021', 'registrationNo': 'TBA97R', 
jschlyter commented 19 hours ago

Do you have access to each others cars?

magnushacker commented 17 hours ago

Yes, we both have both cars in the app.

I think I had to add the second car using the other polestar ID when I set up the integration. Should this work now automatically using just one polestar ID?

leeyuentuen commented 16 hours ago

Should work before on old version: https://github.com/pypolestar/polestar_api/issues/150

magnushacker commented 2 hours ago

I deleted both integration entries and re-added one of them. Only one of the cars show up and when I try to add the second entry using the other polestar ID, it fails and cannot generate devices and sensors. Doesn't matter which one I start with.

I then downgraded to 1.7.2 and experience the same thing.

If I downgrade to 1.6.15, I do get both cars displayed as two devices under the same integration entry.

EDIT: Spoke too soon - sensors on the second car all show as unavailable. If I remove and re-add the entry, I am back to only seeing one car again.

jschlyter commented 1 hour ago

The challenge is most likely that both devices see both cars and there's nothing telling any of them which one to ignore?