Mercedes Me Component

Home Assistant hides items on the map if they are in the “Home” zone.
Check if you have device_tracker.<your registration>_device_tracker, and if it has lat/long in the attributes.

1 Like

Just add a map tile to your dashboard and configure it.
Example

type: map
entities:
  - entity: device_tracker.<your registration>_device_tracker
hours_to_show: 96
default_zoom: 14
theme_mode: auto

I don’t have a separate map (only the standard supplied one), and I do have the car on the map, except when I’m at home.
See: Hide device_trackers from showing on map? - #2 by dshokouhi

got it !
it’s working !
awesome !

thanks !

Correct. I just wanted to show the tracking feature based on my first screenshot.

Download Images using Mercedes Vehicle Images API

Mercedes has a slew of API for various applications, offered to businesses, predominantly for businesses in the EU, and most are available for purchase only.
These APIs are not the one @ReneNulschDE is using for his Home Assistant integration.

Luckily, some APIs are offered on a trial basis, without having a business in the EU.

One of these is the Vehicle Images API, which can used by car dealers to present rendered pictures of the new or used cars they are offering as a basis for a “3D view”. Mercedes has a database of the options of all the cars they manufactures, and they use it to generate images that reflect the individual cars for which the images are requested. Meaning, if your car has blue paint, the images will show a blue car, etc. Its kind of a digital twin of your car:

This tutorial has three part:

  • Getting access to the API
  • Using the API
  • Programs that use the API to download the images

A prerequisit to play along with the manual download is curl, which should come preinstalled on both Windows and Linux. Use it on the terminal/command line of your computer, not in Home Assistant.

Lets start. Click the arrow to expand a section.

Getting Access to the API

Set-up account and API

All of Mercedes’ API are found in the Developers Portal, so you need to get a Mercedes Developer Access.
The address for the Developers site is https://developer.mercedes-benz.com/
On there click Login.

Accept the terms of use:

You will land in your console page, where you need to create your project.

Fill out the form (the details are not relevant or checked as far as I know).

Then inside your project, add a Product:

Select “Vehicle Images”:

As the purchase model, select “Get for Free”. No credit card required.

Choose the “360° Trial” for the Package.

Please note that the free version cames with some pretty hefty restrictions, limiting it to 5 calls. More on that later.

Subscribe, then go to your project page.


There you need to create the API key for your project. Copy it down for further reference.


Thats it for setting up your developers account and activate the Vehicle Images API.

Using the API

Using the API

Go to the page of the Vehicle Images API, either click on the link on your project page, or from the “Products” page.

On the Vehicle Images page, you find the documentation under the appropriately named “Docs” link.

The workflow for getting the images are:

  1. Getting the ImageIds, which are unique IDs tied to both your API key, and the VIN of the car.
  2. Use the ImageIds to download the actual images.

The endpoint for the API is https://api.mercedes-benz.com/vehicle_images/v2

To get the ImageIds, GET the following URL, with the authentification (API key) in the header.
curl -X "GET" "https://api.mercedes-benz.com/vehicle_images/v2/vehicles/<vehicleId>" -H "x-api-key: <insert_your_api_key_here>" -H "accept: application/json"

The result is a JSON output with the ImageIds of each individual image. There are several parameters availabe to influence how the pictures are generated (backgrounds, daytime/nighttime, image parameters, open/closed root for convertibles etc.). See the “Default Image Settings” page.

A sample request looks like this:

Not every car model does have the same number of images available.

With the ImageIds, you can now download the images.
As with the ImageIds, the curl command to GET the images (with the API key in the header) is:
curl -X "GET" "https://api.mercedes-benz.com/vehicle_images/v2/images/<image-id>" -H "x-api-key: <insert_your_api_key_here>" -H "accept: */*"

You may want to include a -o <filename> to save the image.

A sample request looks like this:

Now do that with all the rest of the images that you got from the previous step.

A note about the limit of “5 calls” that we touched on earlier.
As stated by Mercedes in the documentation (under “Caching of Images” section):

Even though all image references are generated dynamically, we will give you a limited time period to get the images from our side. You have to request the images within 24 hours, starting from the time of requesting the image references.

After this time period you will not be able to get the images anymore and you have to request new imageId(s). If you want to use these images for a longer time period, we advice you to store the files on your own.

So as long as you don’t generate new ImageIds, you have all day long to download the actual images.

Automating the Downloads

There is a python script out there that lets you download the images without going through each step indivdually:

As the python script generates the ImageIds on each run, each run may count against the 5 calls from the trial. Haven’t tested that myself.

Thats it, have fun with the stock image of your individual car. I’m looking forward to what you all come up with these images for your Home Assistant instance.

Thomas

3 Likes

Thanks for tutorial. This script downloads all the images to the selected folder according to the set parameters. The limit is 5 calls… so you can set for one folder all car images with background, another call for images without background etc. :love_you_gesture:

Correct. What I don’t know for sure, if you start the script a second time without changing the parameters, will that generate new ImageIds (even though its the same images), and hence counting for two calls?

Each script execution is counted as a call. But I think it is possible to re-generate a new api key on the web :sweat_smile: :rofl:

That won’t reset the 5 calls.

Sorry if I have missed something obvious but I have poured through mutiple threads to no avail.

Some weeks ago the Mercedes Me integration stopped working, I assume that it was due to Mercedes removing the Bring Your Own Car functionality, at least in the UK.

I have removed the integration and started again from scratch but now get Unknown Error Occurred on setting up the integration. The log shows this:
This error originated from a custom integration.

Logger: custom_components.mbapi2020.oauth
Source: custom_components/mbapi2020/oauth.py:224
Integration: mbapi2020 (documentation, issues)
First occurred: 12 June 2024 at 13:37:28 (3 occurrences)
Last logged: 18:13:59

ClientError requesting data from https://bff.emea-prod.mobilesdk.mercedes-benz.com/v1/login: 418, message=“I’m a teapot”, url=URL(‘https://bff.emea-prod.mobilesdk.mercedes-benz.com/v1/login’)

I see that the web interface has gone and the developer portal now demands business access with payment.

Have I got to give up on this in the UK?

Android App still works ok but I think the GUI has changed on that too.

I appreciate the effort and especially software engineering which has gone into this. Fair play to you all and especially Rene!

Hi, Just update to the latest version of the component and reauthenticate if needed…

there is a way to send the pin by script ?
I want to open/lock with siri. I have created a script to expose it to HomeKit, but pin is required and I don’t know if I can sent the pin into the script.

You could configure the PIN in the options of your Hub/account. Then this pin is used by all services that require a pin.

What do you mean by hub ?
Right now I have home assintant with home kit. And there are a Mercedes me integration that prompt a pin when I try to lock/unlock the car.

You are saying there is a place where I can define a default pin that will be used in Mercedes me integration?

On the integration page for the mbapi2020 component, you’ll find the list of your accounts/hubs:

Click on the “Configure” link of the relevant account/hub and add your security pin.

Click on “Save”. The relevant Account/Hub gets reloaded automatically.

1 Like

Thank you so much. :heart_eyes::muscle:t2:

Thank you! My knowledge of Docker is somewhat lacking and the HA version (stable) did not support the latest Merc version. I have learnt a lot today!!

I am now going to try to get the Mercedes card to work.

Can you share some more insights? Normally, I test all new releases with the last 3 HA versions and the next version.

My lack of knowledge is letting me down again! I cannot work out how to find out the last stable release on ghcr.io.

I am pretty sure it was from last year as it started with 2023.

Sorry.