Integration of Polestar 2

Yes, tibber has access to a non public API for the Polestar account :confused:
You have to pair the polestar account in the tibber app.

Hmm. Iā€™ll have to give this a go. Thanks

Hi,

I will get a polestar 2 this week, I donā€™t have any home assistant configured, but Iā€™ve got my own rpis working with some stuffā€¦ This integration for the moment only shows data of the polestar right? I can also publish this into some grafana/prometheus stack, right?

Other point, this week, I donā€™t know how, in duckduckgo, I found this link:
https://api.polestar.com/

I donā€™t know if you know it, butā€¦ feels like we only need to know the endpointsā€¦

Thanks for everything,
D.

The API location is well known. If it was that easy it would have been found by now. A lot of people, particularly in Europe want car information.
The only way to connect are outlined in this thread and on the German and English fan forums. What you do with the data is up to you.
Realistically, the only open way is via the Tibber method, as while CSV is very good, it is restricted on numbers because of the workarounds to get it I. The car.

for people who need more data from tibber

- resource: https://app.tibber.com/v4/gql
    method: POST
    payload: '{"query": "{ me { homes { electricVehicles {id name shortName lastSeen lastSeenText isAlive hasNoSmartChargingCapability imgUrl schedule {isEnabled isSuspended localTimeTo minBatteryLevel} batteryText chargingText consumptionText consumptionUnitText energyCostUnitText chargeRightAwayButton chargeRightAwayAlert {imgUrl title description okText cancelText}backgroundStyle energyDealCallToAction{text url redirectUrlStartsWith link action enabled} settingsScreen{settings {key value valueType valueIsArray isReadOnly inputOptions{type title description pickerOptions {values postFix} rangeOptions{max min step defaultValue displayText displayTextPlural} selectOptions {value title description imgUrl iconName isRecommendedOption} textFieldOptions{imgUrl format placeholder} timeOptions{doNotSetATimeText}}} settingsLayout{uid type title description valueText imgUrl iconName isUpdated isEnabled callToAction {text url redirectUrlStartsWith link action enabled} childItems{uid type title description valueText imgUrl iconName isUpdated isEnabled callToAction {text url redirectUrlStartsWith link action enabled} settingKey settingKeyForIsHidden} settingKey settingKeyForIsHidden}} settingsButtonText settingsButton  {text url redirectUrlStartsWith link action enabled}enterPincode message {id title description style iconName iconSrc callToAction {text url redirectUrlStartsWith link action enabled} dismissButtonText} scheduleSuspendedText faqUrl battery { percent percentColor isCharging chargeLimit}}}}}"}'
    headers:
      Authorization: "{{ states.sensor.tibber_api_access_token.state }}"
      Content-Type: "application/json"
    scan_interval: 15 #15 sec
    sensor:
      - name: "Polestar 2 SOC"
        unique_id: polestar2_soc
        value_template: "{{ value_json.data.me.homes[0].electricVehicles[0].battery.percent | int }}"
        unit_of_measurement: "%"
        icon: mdi:car-electric
        device_class: battery
      - name: "Polestar 2 Battery Charge Limit"
        unique_id: polestar2_battery_charge_limit
        value_template: "{{ value_json.data.me.homes[0].electricVehicles[0].battery.chargeLimit | int }}"
        unit_of_measurement: "%"
        icon: mdi:car-electric
        device_class: battery
      - name: "Polestar 2 Range"
        unique_id: polestar2_range
        value_template: "{{ (value_json.data.me.homes[0].electricVehicles[0].battery.percent / 100 * 375) | int }}"
        unit_of_measurement: "km"
        icon: mdi:car-electric
        device_class: distance
      - name: "Polestar 2 SOC Last Update"
        unique_id: polestar2_soc_lastupdate
        device_class: timestamp
        value_template: "{{ value_json.data.me.homes[0].electricVehicles[0].lastSeen | as_datetime | as_local }}"
    binary_sensor:
      - name: "Polestar 2 Battery Charging"
        unique_id: polestar2_battery_charging
        value_template: "{{ value_json.data.me.homes[0].electricVehicles[0].battery.isCharging }}"
        icon: mdi:car-electric

you will get the following information (need manual add entities that you need)

{
    "data": {
        "me": {
            "homes": [
                {
                    "electricVehicles": [
                        {
                            "id": "xxxxx",
                            "name": "2023 Polestar 2 Space",
                            "shortName": "Polestar 2",
                            "lastSeen": "2023-11-13T09:19:05.000+00:00",
                            "lastSeenText": "Last updated: 44 minutes ago",
                            "isAlive": true,
                            "hasNoSmartChargingCapability": true,
                            "imgUrl": "https://resources.tibber.com/vehicles/Polestar_Space.png",
                            "schedule": {
                                "isEnabled": true,
                                "isSuspended": false,
                                "localTimeTo": "07:00:00",
                                "minBatteryLevel": null
                            },
                            "batteryText": "72%",
                            "chargingText": "Zaptec or Easee charger required to smart charge this car",
                            "consumptionText": null,
                            "consumptionUnitText": null,
                            "energyCostUnitText": null,
                            "chargeRightAwayButton": null,
                            "chargeRightAwayAlert": null,
                            "backgroundStyle": "default",
                            "energyDealCallToAction": {
                                "text": "Activate energy deal",
                                "url": "https://appviews.tibber.com/energy-deal?homeId=xxxxx",
                                "redirectUrlStartsWith": "https://appviews.tibber.com/done",
                                "link": null,
                                "action": null,
                                "enabled": false
                            },
                            "settingsScreen": {
                                "settings": [],
                                "settingsLayout": [
                                    {
                                        "uid": null,
                                        "type": "header",
                                        "title": "Smart Charging",
                                        "description": "This Power-up doesn't work with your current version of the Tibber app. Please update the app on your phone.",
                                        "valueText": null,
                                        "imgUrl": null,
                                        "iconName": null,
                                        "isUpdated": null,
                                        "isEnabled": null,
                                        "callToAction": null,
                                        "childItems": null,
                                        "settingKey": null,
                                        "settingKeyForIsHidden": null
                                    }
                                ]
                            },
                            "settingsButtonText": "How to smart charge this car?",
                            "settingsButton": {
                                "text": "How to smart charge this car?",
                                "url": "https://support.tibber.com/en/articles/6675026-smart-charge-your-polestar-volvo-recharge-with-tibber",
                                "redirectUrlStartsWith": null,
                                "link": null,
                                "action": null,
                                "enabled": false
                            },
                            "enterPincode": false,
                            "message": null,
                            "scheduleSuspendedText": null,
                            "faqUrl": null,
                            "battery": {
                                "percent": 72,
                                "percentColor": "#FFFFFF",
                                "isCharging": false,
                                "chargeLimit": 100
                            }
                        }
                    ]
                }
            ]
        }
    }
}
1 Like

Iā€™ve just quickly set up an integration via HACS. There might be some issues, but itā€™s functional for now.

5 Likes

Iā€™ve noticed that the battery charge limit always shows 100% although my car is set to 90% and my partnerā€™s car is limited to 80%.
Havenā€™t yet tested if this updates to the correct % when charging.
Anyone tested this yet?
I would like to use this info to calculate the remaining charge time.

the integration is the same, because it use the same api call. should be an issue on tibber or polestar api

I guess issue with tibber because our 2nd car is an Audi and shows also 100%.

For those who donā€™t know yet, deleting the ā€˜iconā€™ line for the SoC sensor in your yaml file and because itā€™s device_class: battery, it will show a battery icon in Lovelace representing the actual battery level.


    sensor:
      - name: "Polestar 2 SOC"
        unique_id: polestar2_soc
        value_template: "{{ value_json.data.me.homes[0].electricVehicles[1].battery.percent | int }}"
        unit_of_measurement: "%"
        device_class: battery

Neither the chargeLimit or isCharging works for me. chargeLimit stays a 100% regardless what I set it to in the car. The isCharging is always off regardless if car is charging or not.

Are they working for anyone else?

Same for me, car is charging at the moment, but still 100% limit and isCharging is off.

for people who interest,
iā€™ve create an another hacs where we use direct connection with volvo/polestar API:
This is just an initial commit, could have some issue, but already the first step to direct connect with volvo/polestar API:

1 Like

cool, Iā€™ve added this with success, but the entities have all state unknown, will it take some time before they update maybe?

did you see some error in de log?

maybe vin or the key is incorrect so it canā€™t fetch data from volvo api?

normally you should get de data directly on init.

does this work independent from tibber? I havenā€™t installed the tibber_ev integration.
canā€™t find any errors in log.

canā€™t get it to work, the requests are coming through tho, Iā€™m at 6900 of 10000 requests, but nothing returns it seems. any ideas?

both of them are not related together.

i suppose if the counter goes up, then you key is correct. but maybe you have put the wrong vin?

i have already run them about 14-15 hours and i got

5 812 out of 10 000

maybe i should try put more logs on it.
have you try to start the debug logging ln the integration? then it will also log the debug?

The integration asks for an username and password, but I just linked my github account on the Volvo site for creating an accountā€¦
In other words I did not actually enter a password on the Volvo site. What is the procedure then for the integration username/password?

can you take a look if you here create a account

Volvo ID and create a new volvo id