niklasvieth / polestar-ios-lockscreen-widget

Polestar iOS lockscreen widget via Scriptable
MIT License
26 stars 3 forks source link

Volvo Energy API #1

Closed ccantill closed 1 year ago

ccantill commented 1 year ago

Are there any plans to integrate with Volvo Energy API? It works fine for my PS2 (they don't actually check if the car is linked to your Volvo profile, you can just query the charging status for any Volvo/Polestar EV). The only downside is it requires OAuth2 authentication, so you'd have to set up some kind of website for the web auth flow, AFAIK.

niklasvieth commented 1 year ago

Thanks @ccantill, wasn't aware that the Volvo API is also working for polestar cars and was also surprised that it does not check if the provided VIN is connected to your account 😮

Just tested it and indeed it returns valid and even more data than the Tibber API.

{
  "status": 200,
  "operationId": "<GUID>",
  "data": {
    "batteryChargeLevel": {
      "value": "90.0",
      "unit": "percentage",
      "timestamp": "2023-11-08T18:44:20.467Z"
    },
    "electricRange": {
      "value": "340",
      "unit": "kilometers",
      "timestamp": "2023-11-08T18:44:20.467Z"
    },
    "estimatedChargingTime": {
      "value": "0",
      "unit": "minutes",
      "timestamp": "2023-11-08T18:44:20.467Z"
    },
    "chargingConnectionStatus": {
      "value": "CONNECTION_STATUS_DISCONNECTED",
      "timestamp": "2023-11-08T18:44:20.467Z"
    },
    "chargingSystemStatus": {
      "value": "CHARGING_SYSTEM_UNSPECIFIED",
      "timestamp": "2023-11-08T18:44:20.467Z"
    }
  }
}

Display of the estimated charging time, range and connection status would be indeed nice to have in a widget.

But I also see a bottleneck in the OAuth2 implementation. Volvo will manually validate the application to be published and decide if they want to allow it ... Will look into it, though.

niklasvieth commented 1 year ago

They seem to have closed this way (was anyways a security gap in my opinion)...