Integration of Polestar 2

I’ve been using Home Assistant for a couple of years, and Last week a bought a Polestar 2.
My previuous EV was a Hyundai Ioniq that does not have any app or other means to read the SOC. But I used evNotify to read the status and feed the battery status to both Home Assistant (using REST API sensor) and to ABetterRoutePlanner.com(ABRP) to get better planning for my road trips.
ABRP is also one of the few “native” Polestar apps, and when I log in on the web-page, I also see the SOC that ABRP has recorded. SO it got me thinking. Why not fetch SOC from ABRP.
If I debug the connection in firefox, I can see that through ABRP, I log in to the api at iternio.com:
https://api.iternio.com/1/session/user_login
then
https://api.iternio.com/1/session/get_tlm
which gives me

 status  "ok"
 0       Object { vehicle_id: xxxxxxx, ota_tlm_type: "EVNotify", car_model: "hyundai:ioniq:17:28:other", … }
 1       Object { vehicle_id: xxxxxxxxxxxxx, tlm_type: "automotive", car_model: "polestar:2:23:67:single:sr", … }

and within the second object, i get an object called tlm, which includes
soc 74

Which is the information here:
bilde

Not sure if I should register to get the API-key from iternio.com, or just try to simulate the information from ABRP.

It would give me SOC, if I remember to start ABRP in my Polestar when driving.

3 Likes

Here another workaround to fetch SoC…

Do you have an Android Phone? Can’t see how to add it to Google Assistant on iOS.

Edit: Setting language to English US & region to USA displayed the 'Add Vehicle" option. Seems to continue working when set back to UK.

I’ve been testing with connecting my Polestar to Home Assistant using the google integration.
However, I cannot find a way to bypass voice match verification.

image

service: google_assistant_sdk.send_text_command
data:
  command: "Are my polestar windows open?"

Are you not getting a voice match requirement?

With the new Home Assistant App for polestar I’m capable of getting the cars location and speed. I do have a challenge though as the information is dependent of the actual user (driver). As such I have installed the app on the two users who are using the car the most (third one will be added along the way). Meaning that I have multiple device trackers for the car

The location and attributes are updated when the car is moving and shortly after. As such I need to get the last updated of the two (or more) device_trackers. The speed is calculated as

You could create an automation that is triggered by a state change of the device tracker attribute you are looking at and then store the value in an input_number as ‘last updated’?

1 Like

Does the HA app have to be open or at least started once on the car? Or does it have auto start?

Thx - that helps for the speed and direction.
Any guidelines for the location (to display in a Lovalace map) currently the car is shown two locations (last location of either user) - a thought would be to have conditional cards, but that limits the history of the cars position.

Ah. I take it you cannot just create an additional device tracker to display. But, is it possible to update the attributes from one device tracker with the data from another? Then you could make an automation to do that.

Trigger with a state of the device_tracker.polestar_anna and then let device_tracker.polestar_morten be equal to device_tracker,polestar_anna.

1 Like

Once installed, it will run in the background, just like the app on your phone. You might have to change the settings in the app though - I cannot remember, as I just installed the app and then adjusted it like I do a phone, which was auto pilot (I change phones a LOT).

The app works well in my Polestar, but it does have some quriks, which I think are due to the way that the Polestar is using Android, rather than the app.

  • Location Updating - I cannot get it to do real time. I have tried lots of settings and the shortest it will do is about every two minutes. We have all seen the warnings about battery life for the app on a phone, so I ignored/reversed the settings, but it made no difference.

  • Location again - HA rarely shows the exact location of where the car was last. Right now, my car is reported about 300 yards away and a speed of 8mph, even though it has been on the drive for the last two hours. I think this is because the Polestar shuts down Android immediately, so there is no chance for HA to update the location. I can work around it by detecting it is at home in other ways, but still annoying.

  • Battery charge reading - real pity the app cannot see how much the car is charged, which is probably the biggest thing I would like to be able to integrate. Limitation of the system I guess.

  • Car in use - I haven’t found a way to reliable know the car is in motion (like engine on with a regular car). I thought it was Android Auto On, but that seems be the actual OS when the car goes in to deep sleep after a few days. For the navigation issue noted above, I cannot use speed as the indicator, plus it would false positive if sat at traffic lights or in a jam.

I like the speed template above, fortunately I had similar code already - @motionist you might want to post the actual code, rather than an image for others to use. Anyone else got anything interesting they have done with the app and their Polestar?

Of course the app was not intended for any of this. It is to access your HA installation. Unfortunately it is not very good for that either, using the Vivaldi browser is much better.

This my current YAML package for the Polestar:

#
# *** POLESTAR2 PACKAGE ***
#

# SENSORS:

sensor:

    # create sensor from speed attribute, convert from m/s to km/h
  - platform: template
    sensors:
        polestar2_speed:
            value_template: "{{ (state_attr('device_tracker.polestar', 'speed') | float(0) * 3600/1000) | round(0) }}"
            unit_of_measurement: "km/h"
            friendly_name: "Polestar 2 speed"
            unique_id: 19C744F334

    # create sensor from altitude attribute
  - platform: template
    sensors:
        polestar2_altitude:
            value_template: "{{ state_attr('device_tracker.polestar', 'altitude') | float(0) | round(0) }}"
            unit_of_measurement: "m"
            friendly_name: "Polestar 2 altitude"
            unique_id: A2611371A3

    # create heading sensor from course attribute
  - platform: template
    sensors:
        polestar2_heading:
            value_template: "{{ state_attr('device_tracker.polestar', 'course') | float(0) | round(0) }}"
            unit_of_measurement: "°"
            friendly_name: "Polestar 2 heading"
            unique_id: 9B2A9F1857

    # create direction sensor from heading
  - platform: template
    sensors:
        polestar2_direction:
            value_template: >-
                {% set c = states('sensor.polestar2_heading') | float(0) | round(0) %}
                {%   if  -0.5 < c <  22.5 %} "N"
                {% elif  22.5 < c <  67.5 %} "NE"
                {% elif  67.5 < c < 112.5 %} "E"
                {% elif 112.5 < c < 157.5 %} "SE"
                {% elif 157.5 < c < 202.5 %} "S"
                {% elif 202.5 < c < 247.5 %} "SW"
                {% elif 247.5 < c < 292.5 %} "W"
                {% elif 292.5 < c < 337.5 %} "NW"
                {% elif 337.5 < c < 360.5 %} "N"
                {% endif %}
            friendly_name: "Polestar 2 direction"
            unique_id: C8A249422C


# END

This my current dashboard, not great (compared the Fiat 500e dashboard), but all that can be done.

3 Likes

There is Add CarInfo sensors by drosoCode · Pull Request #3399 · home-assistant/android · GitHub which will bring more information :wink:

Some patience is required

4 Likes

I managed to get the latest GPS coordinates for either of my profiles combined using the following action (when updating speed, altitude and course) - note that the individual device tracker is to be used for each automation:

service: device_tracker.see
data_template:
  dev_id: polestar_common
  gps:
    - "{{ state_attr('device_tracker.polestar', 'latitude') }}"
    - "{{ state_attr('device_tracker.polestar', 'longitude') }}"

Looks like this has now been merged, so just need to wait for a release with this element in it.

1 Like

It is in the beta release in Play now, but the only problem is that with that version the possibility to go into “native” mode to get to app settings has disappeared. So the sensors cannot be enabled as of now, waiting excitingly for a new beta to be released.

2 Likes


With the 2023-08-03 app release, you can also choose specific entities now…
Which means still no dashboard…

I remotely help a friend to get his polestar 2 displayed, so I can’t test it myself

1 Like

Now I’m confused… Just checked and compared the apple Vs android settings and not just didn’t had the Apple app no update since 4 month, but it has no sensors to select for cars etc…