Mercedes Me Component

Not sure here. Maybe lock status is considered sensitive in Italy :man_shrugging:

Maybe try the fuel or vehicle status APIā€™s?

same error for all.
Iā€™ve tried also to modify somethingā€¦ but no luckā€¦
this is my script: https://github.com/xraver/mercedes_me_apiā€¦

That is a great script. Far more elegant than my attempt :slight_smile:

Unfortunately I donā€™t think youā€™ll get this working in Italy. See supported markets in this page:

yup still working for me. Although, I can already imagine my future post announcing it stopped working. Hope Iā€™m wrong.

Hi Rene,

which proto file do i need to use (descriptor.proto, type.proto)?
Can you maybe share your coding?

BR
Sebastian

Today it starts to work also in Italy!!! :slight_smile:

Dear.
after some experiments with new APIs I have a question.
Iā€™m able to retrive the list of resources available. but retriving many of them I get 402 error (No Data). From documentatiom: ā€œIf the vehicle did not send an update for a resource within 12 hours, the response will be emptyā€. Do you have the same behaviour?
in any case I always receive empty message for fuel levelā€¦
thanks

The original component will be fixed with this new API?

Yes, I have the exact same problemā€¦I often get the 402 no data errorā€¦ to troubleshoot I went and started the car and then turned off the car again and locked itā€¦ the 402 went awayā€¦(for a few days)ā€¦ I cant be sure if my ā€œdrivingā€ the car fixed it or if it was pure coincidence.

One problem that I am having often, my node red refesh token seems to work, and I all of a sudden get permission errorsā€¦ then I have to go through the whole ordeal of getting a new tokenā€¦ not sure if I am doing something wrongā€¦ but this oAuth stuff is a pain in the butt.

I too had 402 errors today, driving my car fixed it. I think after a while it goes into a deep sleep mode and stops updating the server with data.

Iā€™m working on a modified version of @kilters excellent NodeRed script to try and make getting the initial OAuth a little easier (saves having to use a REST client) and to allow checking of more data points - will post shortly

1 Like

Sounds great! I had issue getting the syntax right for the auth code. I tried it in a function node and through a http node to no avail. Kept throwing a invalid code error.

Just to confirm I donā€™t think the BYO Car API feeds a historical database on the back end so if you donā€™t use your car for a while you wonā€™t get much data. Similarly I find that if I have not used a particular window in a few days, it doesnt appear in the data.

Iā€™m hoping the connected vehicle API comes out of experimental status soon and that we can use it for our own car.

I had issues with the initial code for a while too! Kept getting ā€˜grant type invalidā€™ errors. All ended up being a formatting issue.

I donā€™t have the custom component installed so instead have fed the data into MQTT sensors. Basically if one of the sensors returns anything other than a 200 OK response it wonā€™t update the sensor, allowing for sensor data persistence in home assistant.

Speaking of data persistence - I tweaked the refresh code loop to allow persistent storage of the refresh token (otherwise if nodered stops then you need to redo everything). It just requires the persistent storage tweak to settings.js.

Will post once I get in front of my laptop!

Iā€™m progressing with my script. now iā€™ve moved into a python code and iā€™m trying to integrate it inside home assistant. unfortunately iā€™ve not a lot of time to work on itā€¦ but iā€™ll try to do all my best. In the standalone python script iā€™ve create a temporary file to cllect the status of all resourcesā€¦ Iā€™ll update the status only if the value is different from 200. in this way iā€™ve created an local historyā€¦

Hereā€™s my updated version of @kilters script - keen to hear how people get on with it. Instructions are included in the flow.

3 Likes

Iā€™m primarily interested in the electric range and the SOC of my C 300de, SOC also can be used to predict how long the charging will take (remaining time).

I have modified the flow accordingly and it is running without problems for a week now.

Many thanks to you @ajoyce

Dear Holger,

Looks great!!!

Can you maybe plase share how you have done it? Which steps are necessary?

Many thanks!

Hi

I know alot have created their own solution and ā€œwork aroundsā€ for getting data from the api, but i thought i would also post my solution.

Possible to get the data to MQTT and it also publishes a little api to get the data into fx. nodered

https://hub.docker.com/r/terpz/mercedesme

Really nice way of collecting the dataā€¦ :slight_smile:

A few small notes:

  1. Would like the topic to be spelled right, mercedesme
  2. Would like to have the VIN in the topic, like mercedesme/ABC123123123/doorlockstatusvehicle (If you have multiple cars you can use multiple containers)

ā€¦ will leave the container running and collect the data for a while and see what I can do with it.

:sweat_smile:woops about the topic.
Fixed it now and it also includes the VIN

do a docker pull and you should be good to go

1 Like

Well, use the nodered flow ajoyce provided above.

Change the scope in the initial code request URL to scope=mb:vehicle:mbdata:evstatus.

Subscribe to the API

Then query

https://api.mercedes-benz.com/vehicledata/v2/vehicles/{{payload.vin}}/resources/soc
https://api.mercedes-benz.com/vehicledata/v2/vehicles/{{payload.vin}}/resources/rangeelectric

and publish values to MQTT.

In HA, set up two MQTT sensors for soc and rangeelectric and display them.

Regarding the remaining time this is a simple calculation in a function node. I estimate 1% charge takes 200 seconds at 10A.

var charge = msg.payload.soc.value;
var remaining = 100 - charge;
if(remaining == 0) {
    msg.payload = "--";
    return msg;
}

var seconds = 200 * remaining;
var hours = Math.floor(seconds / 3600);
seconds = seconds - (3600 * hours);
var minutes = Math.floor((seconds+59)/60);

if(hours == 0) {
    msg.payload = minutes + " Minuten";
}
else {
    msg.payload = hours + " Stunden " + minutes + " Minuten";
}
return msg;

Charging power and temperature (in the plug) is measured by a switchable Shelly Plug S which is plugged into the wall socket. I assume when the wall socket ever gets too hot, the Shelly Plug S will detect this indirectly and switch off (overtemperature protection).