Mercedes Benz integration

Hey Community,
I have created an integration for Mercedes-Benz connected vehicles.

Here you can find all information about installation, use etc.

Discussion so far:



Chris

5 Likes

Thanks for providing this, it is very much appreciated!

There is a minor problem in your web page, as it uses the current url as redirect url. This does not work in case there has been a problem before, as the error message is then appended to the url and also send to mercedes, leading to an “invalud redirect url” error message.

After fixing this, I unfortunately do not get data for a single item. I am wondering if there is a problem with my data or if there simply is no data at all for my car. Do you have an idea?

Regards,
Volker

Hi did you change the redirect url in the Mb-connect.py script ?

This ip address should be the openhab server ip

Your able to see if your car is supported on the Mercedes developer site, pick a API on go to details… there’s a list of supported models

Regards Mads

1 Like

Great to see this initiative. Thank you.
Tried to set it up for my car. Followed the instructions, managed to complete the authentication process. However, when running the script, no data is available for the subscribed APIs. In the ‘Mercedes me’ app, I can see all data points.

## Starting Mercedes Benz API connection ##
# Mercedes Benz API connection successfully established!
# Searching resources for selected scopes:
# No data available for "rangeliquid".
# No data available for "tanklevelpercent".
# No data available for "readingLampFrontRight".
# No data available for "windowstatusfrontright".
# No data available for "rooftopstatus".
# No data available for "windowstatusfrontleft".
# No data available for "sunroofstatus".
# No data available for "doorstatusfrontright".
# No data available for "doorstatusfrontleft".
# No data available for "doorstatusrearright".
# No data available for "interiorLightsFront".
# No data available for "readingLampFrontLeft".
# No data available for "decklidstatus".
# No data available for "windowstatusrearright".
# No data available for "windowstatusrearleft".
# No data available for "lightswitchposition".
# No data available for "doorstatusrearleft".
# No data available for "interiorLightsRear".
# No data available for "doorlockstatusdecklid".
# No data available for "doorlockstatusvehicle".
# No data available for "doorlockstatusgas".
# No data available for "positionHeading".
# All available data has been sent to openHAB!
# Done in 25.094502925872803 seconds

Can anyone tell me what I missed?

Hey Volker,

that’s correct. i use the current viewed page to generate the redirect url. So you don’t have to change the redirect url several times. If you get an error, because e.g. prerequisites are missing, there are currently 2 options.

  1. enter the clean url again into the browser
  2. press the generated error button, this should also call the clean url.

nevertheless thanks for the hint. i can change in a next version.

This is really strange. This message is generated only when everything has worked so far. So your access, API subscription, retrieval of the delivered resources and query of the actual value in the endpoint should work. However, the final query of the value seems to point to “204 - no data”.
This is the reason why I generate the message “# No data available for XXX”.

@pune2001 seems to have the same problem here.

In the first moment I assume that you really have no data. Please check as @Mads_Bloch already described, if your vehicle provides this data in the API.

Otherwise I can give you the hint, in mb-connect.py script edit line 45 “self.debug = False” to “self.debug = True”. If you run the script in the console you will get several new messages. Maybe this helps.

In addition, as mentioned in the readme, I also have a value that is displayed in the Mercedes Me app, but is not retrievable in the API. However, it is only one value for me…

i hope this helps!

Chris

Hello Chris,

thanks for your hint regarding debugging. Switched debug to ‘true’ and found out that in my case, the access token had expired. Fixed it and now it works.

1 Like

Hey,
glad I could help you and it now works for you.

Have fun with it!

Chris

I am also having an issue.

I use latest OpenHAB Version with Docker.
Authentication process worked so far, but when I run the script, there is no data and no error.

APIs are activated as far as i can see:

Do you have any hint for me ?

Hey Christian,

in your screenshot it looks like you did not activate the scope items for the correct auth URL. Please make sure to set the mbc scope items to on and try again.

Chris

I am not sure what to do, can you give me a hint ?

Edit: I found out

Check my readme file and make sure you did all steps.

  1. set your mbc_spope_* items according to your Mercedes-Benz App subscriptions.

    Example: Got to the openHAB console or the sitemap and set every item you subscripted to ON

In the .items file there are this items:

// API scpoes
Switch                  mbc_scope_fuelstatus                  "Fuel Status API"                                                       (gMBC)
Switch                  mbc_scope_evstatus                    "Electric Vehicle Status API"                                           (gMBC)
Switch                  mbc_scope_vehiclelock                 "Vehicle Lock Status API"                                               (gMBC)
Switch                  mbc_scope_vehiclestatus               "Vehicle Status API"                                                    (gMBC)
Switch                  mbc_scope_payasyoudrive               "Pay As You Drive Insurance API"                                        (gMBC)

Didn’t now how to turn them on but managed it now.
Unfortunately still the same result

But the page now shows all APIs as active

In your screenshot above I see only three matching scopes:
Fuel Status, Vehicle Lock, Vehicle Status

So only these three items may be ON:
mbc_scope_fuelstatus, mbc_scope_vehiclelock, mbc_scope_vehiclestatus

the others must be OFF.

If all these requirements match you have to restart the auth process with these settings.
So go to the html page and click again on authenticate button. then back to the script and try again.

Hi… a reason for “response error” could be a wrong VIN number

Regards Mads

1 Like

I did and after re-authentication, MB asked to confirm the asked permissions.

But script still does not receive any data :confused:


Btw I can confirm the issue described above.
If you try to click authenticate after the url was modified with parameters, you will get an error on mb page, claiming you use a wrong redirect_uri.

So you have to clean up the url in browser first and click Authenticate Button again

From where do you get VIN, I only found FIN
Which has 17 numbers and starts with W1N24XXXXXXXXXX46

for my GLA 250 4MATIC

I guess it is the number I should enter right ?

This is The VIN number

1 Like

Yes your VIN looks good. you can it check here:

[SOLVED] …
Hello,

Happy to see that it would now possible to connect my car … Anyway I’m also facing the same issue … ( not data available for … )…

image

image

[ update ] … This seems to be linked with a problem at Mercedes side … even if I don’t know if it’s normal that the application name is sometimes the good one …sometimes set to “Unknown” …

Help is welcome :wink:

[ SOLUTION – In fact, you just have to drive a little bit with your car in order items are also updated at Mercedes side … - Everything’s ok right now. I’m going now to enjoy this new add-on. Thanks again for your work ! – Perhaps good to add this extra comment in the procedure to set up the add-on… ]

Fr,

1 Like

Hey, I’m glad that it now works for you!
Thanks for the hint, I will let it flow into the readme.

have fun with it!

Chris