Integration of Polestar 2

Managed to figure out the authentication flow which took me quite a few hours! I will document this properly tomorrow.
I’ve just plugged my car in and taken a look at the data whilst it’s on charge:

{
  data: {
    getBatteryData: {
      averageEnergyConsumptionKwhPer100Km: 23,
      batteryChargeLevelPercentage: 84,
      chargerConnectionStatus: 'CHARGER_CONNECTION_STATUS_CONNECTED',
      chargingCurrentAmps: null,
      chargingPowerWatts: null,
      chargingStatus: 'CHARGING_STATUS_CHARGING',
      estimatedChargingTimeMinutesToTargetDistance: null,
      estimatedChargingTimeToFullMinutes: 35,
      estimatedDistanceToEmptyKm: 320,
      estimatedDistanceToEmptyMiles: 200,
      eventUpdatedTimestamp: {
        iso: '2023-12-18T00:57:51.000Z',
        unix: '1702861071',
        __typename: 'EventUpdatedTimestamp'
      },
      __typename: 'Battery'
    }
  }
}

Charging amps/current remains at null which is a shame, but estimatedChargingTimeToFullMinutes is populated which is handy.

2 Likes

I’ve published a node.js module here:

I’ve not written a Home Assistant component before, but if someone does I hope this helps. I will probably use this module to write something that just spits the car data out over MQTT.

Isn’t @leeyuentuen doing that? IMPORTANT! Volvo Energy API is down · Issue #10 · leeyuentuen/polestar_api · GitHub
Or are there now 2 separate tracks? :slight_smile:

yes indeed it is moreless the same. should be release in the next few days. just testing now.

3 Likes

Didn’t realise @leeyuentuen was updating his to use the Polestar API

updated polestar api to fetch data.
the best way is first remove the old ‘settings’ and add a new one

2 Likes

Thank you for your work!
I had the beta version when it worked, until it didnt…

i updated to 1.0.4. After entering login credentials i get an unknown error, Unexpected error creating api.

I did delete the whole integration from hacs, and a second, third and forth time i tried manually delete from file explorer and hacs and different combinations. Older versions give the same error.

How do I delete the old settings so i can start off fresh?

Hello
I have just installed the HACS integration and have not used it before.
I can log in on the Polestar website, but the HA integration is also returning Unknown Error with me.

I have really nåbeen looking forward to this integration as I have just picked up my Polestar 2 :slight_smile:

you select there the delete to delete that device.

the vin will be request from your polestar account (where you have add your vin)

can you see your car in polestar account?

https://polestarid.eu.polestar.com/as/authorization.oauth2?response_type=code&client_id=polmystar&redirect_uri=https%3A%2F%2Fwww.polestar.com%2Fsign-in-callback&scope=openid%20profile%20email%20customer:attributes%20customer:attributes:write

if you see in the log, do you see the reason for the error?
on the latest beta version, there is more logging added to troubleshoot. maybe add the log or put your issue in the gitlab issue for better followup

Found out my car is not connected to my Polestar ID account. I have asked Polestar to look into this. Then I will try the HA intrgration again.

Have the same. My car is not eligible for ownership due its a lease, is this new? Before it was working :frowning:

Strange, I have a lease as well (Belgium) and works perfectly. Both on Polestar website and in with the integration from @leeyuentuen .

This is great. Thank you @leeyuentuen

Here is my dashboard if useful to anyone else:

type: grid
square: false
columns: 1
title: Car
cards:
  - camera_view: auto
    type: picture-glance
    image: /local/Polestar2.png
    entities:
      - entity: sensor.polestar_7241_battery_charge_level
  - type: entities
    entities:
      - entity: sensor.polestar_7241_battery_charge_level
      - entity: sensor.polestar_7241_estimate_distance_to_empty_miles
      - entity: sensor.polestar_7241_charging_status
      - entity: sensor.polestar_7241_current_odometer_meters
    state_color: true
    show_header_toggle: false
    footer:
      type: graph
      entity: sensor.polestar_7241_battery_charge_level
      detail: 2
      hours_to_show: 168
1 Like

Fantastic! I now have data from my Polestar from three sources, from the HA AAOS app (although I think that broke recently), from Tibber EV and now from the Polestar API. The latter two both thanks to @leeyuentuen. Thank you indeed!

While charging, ‘charging current’ and ‘charging power’ remain “Unknown”, and ‘charging time’ just sits at “240 minutes” for me. Is that just me?

When I first started the integration ‘Model’, Vehicle registration’, and ’ VIN’ showed correctly very briefly, ever since they just show ‘Unknown’. Is that just me?

And, can I make a few suggestions:

  • The unit for energy consumption should be “kWh/100km”.
  • “Average Speed Per Hour” is weird, should be “Average Speed” with the unit “km/h”.
  • “Odometer Meter” should be just “Odometer”
  • Default odometer number of decimals should probably be 0
  • Generally the capitalization of the friendly names is inconsistent.

1 Like

To clarify some of my own queries after finishing a charge:

The ‘Charging time’ shows the estimated time to finish the charge, first at a resolution of hours (60 min) and then at a higher resolution (first 15 and then 5 min) towards the end of the charge. Makes sense.

The ‘Model’, ‘Registration’ and ‘VIN’ showed up correctly a few times just after installing the integration, but then never again. Don’t know what’s up with that.

Also the ‘Charger Connection Status’ shows correctly as ‘Connected’ or ‘Disconnected’, but it does not show a history?

The API seems to be a bit flakey and goes up and down a lot, but isn’t detected. If you find a lot of unknowns for the sensors etc, then just reload the integration and it will pull the information in.

I have seen the information go quickly as well, the API token expiry time is usually old, so it hasn’t refreshed correctly.

thanks for review. There are already few beta changes in the last 24 hours,
can you take a look at this version: Release 1.2.9 · leeyuentuen/polestar_api · GitHub
and see if the issue still exists.
Also some comments from you above should also changed.

if there is still some issue, just open an issue ticket on github for better follow-up

1 Like

i have tried to catch the exception (timeout, read errors) to make sure that we don’t need to reload the integration. if you still have the issue on the latest beta, just create an ticket with the log that you have, so i can investigate and prevent this issue happend again.

1 Like

Just use on call in your polestar and ask if support can add your car to your account. They did it for my car too.

1 Like