Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undocumented API endpoints for charge control of hybrid vehicles #88

Open
hollie opened this issue Jun 18, 2022 · 9 comments
Open

Undocumented API endpoints for charge control of hybrid vehicles #88

hollie opened this issue Jun 18, 2022 · 9 comments

Comments

@hollie
Copy link

hollie commented Jun 18, 2022

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.

@Gadgit83
Copy link

Gadgit83 commented Sep 1, 2022

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.

@Gadgit83
Copy link

Gadgit83 commented Sep 1, 2022

@Gadgit83
Copy link

Gadgit83 commented Sep 1, 2022

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"}}'

@hollie
Copy link
Author

hollie commented Sep 2, 2022

@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.

@klara31
Copy link

klara31 commented Nov 9, 2022

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

@BernoldNL
Copy link

BernoldNL commented Apr 3, 2023

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.

@Gadgit83
Copy link

Gadgit83 commented Apr 3, 2023 via email

@nikagersonlohman
Copy link

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.

@klara31
Copy link

klara31 commented Feb 6, 2025

I have a Since last week, I am not getting my chargeLocations from my V60 2021 recharge. When issueing:
https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/{{VIN}}
this returns:

{
    "attributes": "https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/MYVIN/attributes",
    "status": "https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/MYVIN/status",
    "vehicleAccountRelations": [
        "https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicle-account-relations/MYID"
    ],
    "vehicleId": "MYVIN"
}

however, when issueing:
https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/{{VIN}}/chargeLocations?status=Accepted
I get:

{
    "errorLabel": "VehicleDoesNotExist",
    "errorDescription": "The Vehicle does not exist"
}

I already tried to remove the chargeLocation from the app, logged out and back in again, removed and reinstalled the app, all without result. This is pretty annoying as this eliminates the possibility to control charging from a script.
Am I the only one with this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants