molobrakos/volvooncall

Undocumented API endpoints for charge control of hybrid vehicles

Opened this issue · 8 comments

Hello,

Thanks for the code that allows us to interface with VOC.

I am using two undocumented API endpoints to be able to suspend the charge process of my hybrid vehicle.

It might be interesting to add these two endpoints to the code. The first one allows to fetch all known charge locations, the second one allows to control the charge times at a specific charge location.

I have documented the two API endpoints here. I have not yet written the code to be able to create a pull request as I don't know what would be the best way to integrate this feature in the software you wrote.

Best regards,
Lieven.

This would also be really great if we could integrate this feature, I can see that it's currently being used by Homey, and people appear to be using without issue. This would be really valuable for smart charge control.

I think it could be done with an addition of a property for charging locations in here:

async def call(self, method, **data):

and the addition of a call to /chargeLocations/ with the data

"delayCharging":{"enabled":${delayedCharging},"startTime":"${startTime}","stopTime":"${endTime}"}

but I can't really see how to feed the startTime and endTime through from anywhere - although for my purposes it would probably work to just set the delayedCharging to toggle on and off with startTime and endTime either not set or staying the same as the data from the charge location.

In fact, I've just successfully achieved the same thing using the Home Assistant rest_command feature, which might work for you- add this in to your configuration:

rest_command:
  volvo_force_charging_on:
    url: "https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/YOURVINHERE/chargeLocations/YOURCHARGINGIDHERE"
    method: put
    username: !secret volvo_username
    password: !secret volvo_password
    headers:
      x-device-id: Device
      x-os-type: Android
      x-originator-type: App
      x-os-version: 22
      content-type: application/json
    payload: '{"status": "Accepted","delayCharging": {"enabled": false,"startTime": "00:30","stopTime": "04:30"}}'
  volvo_force_charging_off:
    url: "https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/YOURVINHERE/chargeLocations/YOURCHARGINGIDHERE"
    method: put
    username: !secret volvo_username
    password: !secret volvo_password
    headers:
      x-device-id: Device
      x-os-type: Android
      x-originator-type: App
      x-os-version: 22
      content-type: application/json
    payload: '{"status": "Accepted","delayCharging": {"enabled": true,"startTime": "00:30","stopTime": "04:30"}}'

@Gadgit83

just confirming that I am using the API calls without issues to delay the charging of my car in the evening until the sun rises in the morning. I post this to confirm your statement 'people appear to be using without issue'.

I am one of those people 😄

Best regards,
Lieven.

Is this functionality going to be integrated in voc? Unfortunately I lack the programming skills to implement it myself...

I thought I'd share some more undocumented endpoints that I haven't seen here yet. Didn't want to open a new issue, as it's not a real issue, just info. So hope you don't mind. Hoping others can confirm and add info. I'll be using any additional endpoint for my HomeSeer HS4 Volvo Plugin.

GET https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/VIN/updatestatus
I think I first saw this in the code for the Homey implementation. As far as I know, this updates the status of some items while the car is off. Things like HV Battery Level (otherwise you will only see each 25%), doors, etc.

Next, some reverse engineering by myself.

To set the preclimatization timers:
POST https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/VIN/preclimatization/set_timers
Body in JSON should look like this:

For Timer1: {"timers":{"timer1":{"activate":true,"time":"20:30"}}}
For Timer2: {"timers":{"timer2":{"activate":true,"time":"20:30"}}}

Ofcourse activate can be true (=on) or false (=off). And time if in HH:mm, so in 24h format and with leading zero for 00-09.

To set the heater timers:
For cars with a heater, instead of preclimatization, the endpoint seems to be:
POST https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/VIN/heater/set_timers
I would appreciate it if anyone with a heater can test this and confirm.

And then there's:
GET https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/VIN/preclimatization/calendar
POST https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/VIN/preclimatization/calendar/updatestatus

This may have something to do with setting the day of the week for Timer1 and Timer 2, as seen in the app. But I didn't get any further with this, as my car does not support it.

To send a destination to the navigation:
POST https://vocapi.wirelesscar.net/customerapi/rest/vehicles/VIN/pois
(Note, this is not under v3.0)

Body in JSON should look like this:
{"pois":[{"description":"Description of the location that will be shown in navigation","name":"Description of th…","position":{"latitude":51.898943,"longitude":5.194614}}]}

I have not yet figured out where/how name is used. It seems to be just a truncated version (18 chars incl. "…") of description.

Note that you will need 2 additional/alternative headers besides the usual x-originator-type and x-os-type:
Content-Type: application/vnd.wirelesscar.com.voc.POIS.v4+json; charset=utf-8
Accept: application/vnd.wirelesscar.com.voc.Service.v4+json; charset=utf-8

I will probably have some more. Let me know if there is anything you're still looking for.

If the new XC90 also has Android Automotive, it will not support the "old" vocapi commands. Please test the following:
https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/**YOUR_VIN_HERE**

If that returns "VehicleDoesNotExist" it will not support your vehicle and hence those undocumented API endpoints will not work either.