Page 1 of 8
Mercedes Me (Connected Vehicle)
Posted: Friday 21 August 2020 21:50
by kiddigital
Mercedes (Diamler) is offering (cloud) connectivity of their vehicles by which the state of the vehicle can be read remotely. Primarily used by their
Mercdes Me app so user can get different types of information of their car on their mobile.
The collected data can also (for the most part) be read via their API's provided that you have the right credentials to do so.
Since June 2020, Mercedes offers a so-called BYOCAR (Bring Your Own CAR) license plan for some of their API's. This license plan is free (at the moment at least) but you need to have a valid Mercedes Me account (and of course the Mercedes car that has been bound to that account, usually your own car
).
Mercedes has stopped their BYOCAR product per September 2023! So the domoticz integration does not work anymore.
In the 2020.2 Beta of Domoticz (or actually just a
Pull Request on Github at the moment of writing) a new hardware type
Mercedes Me Connect is added that with the correct parameters and credentials, reads the data from these API's and present the values as sensors in Domoticz.
Once you have these sensors in Domoticz, you can use these to either perform actions, show them on your dashboard (or alternative dashboard like
Dashticz), or create a floorplan like done
here for a Volvo.
This topic is here to collect questions, feedback, etc. for this integration.
Some screenshots (beta):
- dmtcz_mercedesme_hw.png (38.39 KiB) Viewed 5647 times
- dmtcz_mercedesme_dev.png (96.43 KiB) Viewed 5647 times
- dmtcz_mercedesme_floorplan.png (195.54 KiB) Viewed 5647 times
Re: Mercedes Me (Connected Vehicle)
Posted: Friday 21 August 2020 22:13
by kiddigital
JimmyH1969 wrote: ↑Friday 21 August 2020 17:21
kiddigital wrote: ↑Tuesday 18 August 2020 18:12
JimmyH1969 wrote: ↑Tuesday 18 August 2020 9:29
Hi, Thanks!, but I'm using Domoticz on Windows. How can i test this Pull Request?
As this is still a PR and not yet part of the Beta, you need to build it yourself from the
source repo of the Pull Request. Hopefully that is an option
I really have no idea how to build the Windows executable from that
I wish....
Think i have to wait until it is available in a beta version i guess...
I also don't understand this part, can you explain a bit more maybe?
To register you own Mercedes, you have to register with your existing Mercedes Me account at 'https://developer.mercedes-benz.com/' and request access for all 5 BYOCAR API's. Each of those API's has its own scope, so within the request for an access- and refresh token, all 5 scopes have to be supplied (space separated).
Thanks, i do hope to get this working on my Windows Domoticz some day
@JimmyH1969, I assume you have been able to login to the Developers portal using your Mercedes Me account? (Must be the same one that you use in the app and has been registered with your car. In my case that was done by the dealer as they are I think the only ones that can bind a/your car to your account). Is that correct?
Within the developers portal you need to access the 'console'. Here you see your information.
- First you need to have/create an App. Can be anything and you only need 1, I called mine Domoticz but any name is fine.
- The purpose URL can also be anything. I just linked to the Domoticz website.
- Once you have an app, now you can choose one of the API and press 'Get Access'. Here select the created application to link the API to this APP.
- If you look in the Console now, you see within the APP that an API section is added which shows the API you now have access to, but also shows the OAuth2 credentials you need consisting of a Client ID and Client Secret. These are important.
- For OAuth, you need to add a Redirect URL which you can do in the Console. Create a Redirect URL with the value https://localhost
- At this moment, for 5 API's a BYOCAR license can be requested and added to your console.
- mercedes-dev-console.png (57.75 KiB) Viewed 5593 times
Once you have the licenses for these 5 API's added to your App (should be visible in the console), it becomes possible to start the OAuth2 authorisation process.
First an
authorization token has to be requested. Look at the URL below and fill in your own OAuth Client ID (see Console).
Code: Select all
https://ssoalpha.dvb.corpinter.net/v1/auth?response_type=code&client_id=<PUT-YOUR-CLIENT-ID-HERE>&redirect_uri=https://localhost&scope=openid%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:payasyoudrive%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20offline_access&state=test&prompt=login%20consent
( The old URL was
- Spoiler: show
Code: Select all
https://id.mercedes-benz.com/as/authorization.oauth2?response_type=code&client_id=<PUT-YOUR-CLIENT-ID-HERE>&redirect_uri=https://localhost&scope=mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:payasyoudrive%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20offline_access&state=test
and before that
Code: Select all
https://api.secure.mercedes-benz.com/oidc10/auth/oauth/v2/authorize?response_type=code&client_id=<PUT-YOUR-CLIENT-ID-HERE>&redirect_uri=https://localhost&scope=mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:payasyoudrive%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus&state=test
)
Put the URL in your browser and you should be getting the Mercedes Me Login screen where you can login and have to approve access to the data for the App you created. You can actually see in the Mercedes Me portal (not the mobile App!) which applications have access to your data and even when they accessed it (Nicely done Mercedes
)
The browser want to redirect your to the URL the has been provided as the Redirect URL (
localhost remember
) and that is actually your local machine. If you look at the browser URL, it should contain an authorization token as part of the URL. This auth token is the one you need to fill in on the hardware settings screen (as the password).
BTW: more information can also be found at the OAuth2 documentation of the Develop website at
https://developer.mercedes-benz.com/con ... umentation
Re: Mercedes Me (Connected Vehicle)
Posted: Sunday 23 August 2020 12:32
by JimmyH1969
Thanks for the explanation. When it's in a Beta version i'll give it a go
Re: Mercedes Me (Connected Vehicle)
Posted: Thursday 27 August 2020 21:50
by JimmyH1969
Also reading/following the Pull Request comments. Things seem to be working out pretty nice.
Will there be an option to get the location of the car?
Re: Mercedes Me (Connected Vehicle)
Posted: Friday 28 August 2020 7:45
by kiddigital
JimmyH1969 wrote:...
Will there be an option to get the location of the car?
At the moment the Mercedes API’s does not expose the cars location unfortunately. Only Heading (0-360 degrees) is available.
In the Mercedes Me app it is possible to define ‘Areas’ (geofences around a certain point) and get alerts if the car enters or leaves an area. I hope (and will ask the devs) if they can at least make these alerts available as the owner of the car knows where each area is and so the owner gets a good idea where the car is without having to receive detailled coordinates. Which is something I think Mercedes is very reluctant to share (while Tesla for example does share this).
BTW: at the moment (28-8-20) Mercedes is having (and reporting) issues with their API’s. They are unavailable at the moment. See their
Status page for details.
Re: Mercedes Me (Connected Vehicle)
Posted: Monday 31 August 2020 15:05
by sieth
Hello people,
I have a question:
This error :
Error: MercApi: Failed to get token.
Error: MercApi: Failed to refresh login credentials.
Is this of the service being down by Mercedes or a misconfiguration by my side??
I've followed all steps as described (I think
)
Many thanks in advance!!
Re: Mercedes Me (Connected Vehicle)
Posted: Monday 31 August 2020 15:48
by kiddigital
sieth wrote:Hello people,
I have a question:
This error :
Error: MercApi: Failed to get token.
Error: MercApi: Failed to refresh login credentials.
Is this of the service being down by Mercedes or a misconfiguration by my side??
I've followed all steps as described (I think
)
Many thanks in advance!!
Both
The log message indicates that Login was not succesfull.
The API services still seem down, but the Auth service does work.
After succesful login, you should see failures trying to get the info from the car.
At the moment you have to provide a valid refreshtoken. Thats one step more than what the (unfinished) description now says. (Sorry for that... time
)
Re: Mercedes Me (Connected Vehicle)
Posted: Monday 31 August 2020 18:18
by kiddigital
JimmyH1969 wrote: ↑Sunday 23 August 2020 12:32
Thanks for the explanation. When it's in a Beta version i'll give it a go
Today (31 August 2020) the latest Beta release of Domoticz (2020.2.12313) contains the Mercedes Me implementation.
Unfortunately, Mercedes is still reporting issues with their API's, so actual testing is limited as the API's are not reporting any car data at the moment. But testing the setup and authorization is possible, so any feedback there is already welcome.
Re: Mercedes Me (Connected Vehicle)
Posted: Monday 31 August 2020 18:42
by sieth
Ok, so clearly I did something wrong than.
I've included some screenshot's maybe someone else can see my mistake.
- merc1.jpg (34.57 KiB) Viewed 5540 times
- merc2.jpg (80.35 KiB) Viewed 5540 times
- merc3.jpg (4.54 KiB) Viewed 5540 times
This is the errors i've got:
2020-08-31 18:40:41.819 Status: Received 400/401.. During authorisation proces. Aborting!
2020-08-31 18:40:41.819 Status: Mercedes: Aborting due to too many failed authentication attempts (and prevent getting blocked)!
2020-08-31 18:40:41.819 Status: Mercedes: Worker stopped...
2020-08-31 18:40:41.819 Error: MercApi: Failed to get token.
2020-08-31 18:40:41.819 Error: MercApi: Failed to refresh login credentials.
I've been curious what mistake i'm making here
Re: Mercedes Me (Connected Vehicle)
Posted: Monday 31 August 2020 20:06
by kiddigital
sieth wrote: ↑Monday 31 August 2020 18:42
Ok, so clearly I did something wrong than.
I've included some screenshot's maybe someone else can see my mistake.
merc1.jpg
I see you have 3 of the 5 BYOCAR licenses added to your profile. Add EV (even if you don't have an EV) and Pay-as-you-Drive.
sieth wrote: ↑Monday 31 August 2020 18:42
merc2.jpg
Looks ok. Just to double check: username contains both the
client_id AND
client_secret with a
colon in between?
sieth wrote: ↑Monday 31 August 2020 18:42
merc3.jpg
Nice
With each change in licenses (and/or when some time (few hours) has passed) you need to re-do this to get a new authorization code as the current/old ones expires.
sieth wrote: ↑Monday 31 August 2020 18:42
This is the errors i've got:
2020-08-31 18:40:41.819 Status: Received 400/401.. During authorisation proces. Aborting!
2020-08-31 18:40:41.819 Status: Mercedes: Aborting due to too many failed authentication attempts (and prevent getting blocked)!
2020-08-31 18:40:41.819 Status: Mercedes: Worker stopped...
2020-08-31 18:40:41.819 Error: MercApi: Failed to get token.
2020-08-31 18:40:41.819 Error: MercApi: Failed to refresh login credentials.
I've been curious what mistake i'm making here
At the above log is indeed saying that the authorization process fails.
At the moment the process is not really user-friendly yet (trying to work on that
).
The 'missing' step, I will update the docs asap, is that although the setup screen already says that you need to enter the
Authorisation code you received (which you did in screenshot 3), you still have to enter the 'refresh token' (or you can enter the refreshtoken within the 'user variables', see
setup/more options/user variables). Therefor you need to perform one more step once you have a valid Authorisation code:
Code: Select all
curl --location --request POST 'https://api.secure.mercedes-benz.com/oidc10/auth/oauth/v2/token' \
--header 'Authorization: Basic <BASE64 Encoded client_id:client_secret>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'code=<PUT_YOUR_AUTHORISATION_CODE_HERE>' \
--data-urlencode 'redirect_uri=https://localhost' \
--data-urlencode 'grant_type=authorization_code'
The above command (you can run it on your PI or most other shells) has 2 items to fill-in correctly. The AUTHORISATION_CODE from the previous step. And a base64 encoded representation of the string you entered in the 'username' field of the setup screen. You can use base64encode.org (privacy mode just to be sure) or a command like
Code: Select all
echo '<client_id>:<client_secret>' | base64
The curl command should return JSON output with contains several things including an access_token and refresh_token. The refresh_token value is the one that you have to enter. When you press 'update' in the setup screen, Domoticz will restart the Mercedes Me hardware and the new value will be used. Within the log you should see a log message stating that login was succesful (and for now also logs the new refresh_token it received and stored internally).
I hope to remove the need for this step asap and let the program take care of this.
Re: Mercedes Me (Connected Vehicle)
Posted: Friday 04 September 2020 14:34
by kiddigital
kiddigital wrote: ↑Monday 31 August 2020 20:06
...
I hope to remove the need for this step asap and let the program take care of this.
In Beta 2020.2.12337 a few improvements are available and the main one is that you now just have to enter the
Authorisation_code as the hardware settings screen says (and not a valid refresh_token anymore so that step is obsolete).
Re: Mercedes Me (Connected Vehicle)
Posted: Friday 04 September 2020 14:38
by kiddigital
JimmyH1969 wrote: ↑Sunday 23 August 2020 12:32
Thanks for the explanation. When it's in a Beta version i'll give it a go
GO
Re: Mercedes Me (Connected Vehicle)
Posted: Tuesday 08 September 2020 9:52
by mbdeveloper
Dear developers,
MB /developers team loves your engagement with the Mercedes-Benz APIs. Feel free to contact us directly in case of any issues with the connected APIs and our BYOCAR initiative. Some valuable links:
https://developer.mercedes-benz.com/news/byocar
car-simulator.developer.mercedes-benz.com
Mercedes-Benz /developers team
[email protected]
Please be informed, that "WE’RE CURRENTLY FACING ISSUES WITH OUR CAR-RELATED DATA PRODUCTS AS WELL AS WITH THEIR RESPECTIVE BYOCAR SOLUTIONS." We are aware of it and working on it.
Re: Mercedes Me (Connected Vehicle)
Posted: Saturday 19 September 2020 17:53
by kiddigital
At the moment Mercedes is still having issues with their API's, see this
status page.
Secondly, they recently introduced an updated (more secure I guess) OAuth service where we have to migrate to before the end of October 2020. See
here for more information. And I guess that most people with a developer account at Mercedes have been informed by mail (at least I have).
A
Github issue has been created on the Domoticz Github so it is known that a migration is needed and I am working on it, but due to the other API's being unavailable still, it is hard (impossible) to complete the needed updates and create the Pull Request for Domoticz.
More to follow soon I hope.
Re: Mercedes Me (Connected Vehicle)
Posted: Thursday 24 September 2020 8:52
by mbdeveloper
Dear All,
we have fixed our issues with the connected vehicle API's (BYOCAR API's) and completed successfull tests. We invite you to continue working with the API's.
Please let us know if you are faced with further issues: developer.mercedes-benz.com/contact or via email to
[email protected].
Any first time connect triggers some replication processes in the underlying backend systems and will take some time. Further, you have to trigger some status changes. So, please move the car and retry the connection.
Best,
Mercedes-Benz /developers team
Re: Mercedes Me (Connected Vehicle)
Posted: Wednesday 30 September 2020 7:58
by mbdeveloper
Dear developers!
we hope you can work with stable APIs now. Beside doing our homework we are working on additional data points, like GPS as well as on additional features which we plan to release in the next couple of months. So please stay tuned.
Furthermore, we would be happy to get your input on features and data points you really need. Let us know - developer.mercedes-benz.com/contact or
[email protected].
Best Wishes,
MB /dev team
20.10.20:
- Added link to get more information about the BYOCAR (bring-your-own-car) products and usage
https://developer.mercedes-benz.com/news/byocar
- Please consider, that the connect vehicle products are limited to specific markets. The error message "This vehicle / user combination is not valid." could also indicate this limitation. Please check the country list in the 'detail' section of each product (e.g.
https://developer.mercedes-benz.com/pro ... ce/details).
Re: Mercedes Me (Connected Vehicle)
Posted: Saturday 03 October 2020 18:17
by kiddigital
At the moment, the Mercedes API's are available and stable again
In Domoticz Beta build 12400 and up (today 12449 can be downloaded) an update has been introduced that switches to the new Authentication API Mercedes recently introduced. Everything works fine now, but the first step in getting an
Authorization token has a different URL now:
Code: Select all
https://id.mercedes-benz.com/as/authorization.oauth2?response_type=code&client_id=<PUT-YOUR-CLIENT-ID-HERE>&redirect_uri=https://localhost&scope=mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:payasyoudrive%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20offline_access&state=test
Fill in your clientID and put it into your browser. You should get the Mercedes Me login page and after succesfull login, you should be redirected to a localhost URL containing the token.
(I will update the URL in the opening post as well)
Re: Mercedes Me (Connected Vehicle)
Posted: Wednesday 14 October 2020 13:42
by kiddigital
Hi @sieth and @JimmyH1969 , I was wondering if you were already able to try the Beta and what your experiences are with the new Mercedes Me integration in Domoticz? Thx
Re: Mercedes Me (Connected Vehicle)
Posted: Thursday 15 October 2020 14:07
by JimmyH1969
kiddigital wrote: ↑Wednesday 14 October 2020 13:42
Hi @sieth and @JimmyH1969 , I was wondering if you were already able to try the Beta and what your experiences are with the new Mercedes Me integration in Domoticz? Thx
Hi there,
Sorry, no time yet. I will see if i can update my test domoticz machine and get this going.
Thanks in advance
Re: Mercedes Me (Connected Vehicle)
Posted: Wednesday 16 December 2020 11:57
by mbdeveloper
Dear All,
we have solved some issues with the refresh token which should work now smoothly. The token validity will be 30 days.
Best,
Olaf from Mercedes-Benz /developers