/MMM-MercedesMe

Primary LanguageJavaScriptMIT LicenseMIT

MMM-MercedesMe

This an extension for the MagicMirror. It can display your Mercedes car electic/fuel and range on Magic Mirror2. You can add multiple instances with different Mercedes cars.

MMM-MercedesMe Screenshot MMM-MercedesMe Screenshot

Installation

  1. Navigate into your MagicMirror's modules folder and execute git clone https://github.com/ashishtank/MMM-MercedesMe.git. A new folder should appear.
git clone https://github.com/ashishtank/MMM-MercedesMe.git
  1. No need for npm install as it uses depencies from Magic Mirror2 core.
  2. You need minimum Magic Mirror version 2.14.0 for this module to work.

Using the module

To use this module, add it to the modules array in the config/config.js file:

modules: [
	{
		module: 'MMM-MercedesMe',
		position: 'bottom_right',	// This can be any of the regions. Best results in left or right regions.
		header: 'My Mercedes', // This is optional
		config: {
			// See 'Configuration options' for more information.
		}
	}
]

Configuring App and Retrieving API Token

There is mandatory MercedesMe registration required, you may use your Mercedes Me credentials

Go to Developer.MercedesMe. Follow below steps:

  1. Click on Add New App and fill below details.
Application Name: My Mirror App
Purpose URL: https://github.com/ashishtank/MMM-MercedesMe
Business Purpose : BYOC (Bring your own car) you can write any thing here
AUTH CALLBACK URL: http://localhost

MMM-MercedesMe Screenshot

  1. Hit create and you'll be displayed your App ID. MMM-MercedesMe Screenshot

  2. Now go to Electric Vehicle or Vehicle Status to subscribe to your car status for Mirror App based on your car type, if you have multiple cars you can subscribe to them in this single app as well.

  3. Make sure Mirror app is selected in the subscribe list and click on subscribe MMM-MercedesMe Screenshot

  4. It should display below confirmation window, click on view in console MMM-MercedesMe Screenshot

  5. In console it should show you app with electic vehicle or vehicle subscription as below with client id and client secret MMM-MercedesMe Screenshot

  6. We will need to add correct redirect url here, click on + button next to redirect urls and redirect url http://localhost:8080/MMM-MercedesMe/callback. This is local url of Magic Mirror as we will get token on mirror only. MMM-MercedesMe Screenshot

  7. Press Ok icon as shown in image above to add the callback url to app. MMM-MercedesMe Screenshot

  8. Now configure the module with below Configuration options, we will get the token in few next steps

Configuration options

The following properties can be configured:

Option Description
clientID Your MercedesMe Mirror App client id, you can get it here.

Possible values: string
Default value: none
This value is mandatory
client secret Your MercedesMe Mirror App client secret, you can get it here.

Possible values: string
Default value: none
This value is mandatory
vehicleId Your Mercedes Vehicle id can be VIN or FIN.

Possible values: string
Default value: none
This value is mandatory
vehicleType Vehicle type, based on your vehicle type correct subscription in mirror app is needed i.e. Electrive Vehicle or Vehicle status

Possible values: Electric, Petrol, Diesel
Default value: Electric
scope Scope, only needed if vehicle is not an electic car

Possible values: mb:vehicle:mbdata:evstatus offline_access or mb:vehicle:mbdata:vehiclestatus offline_access or both
Default value: mb:vehicle:mbdata:evstatus offline_access
displayStyle Display style of vehicle data on Magic Mirror2.

Possible values: singledial, twodial
Default value: singledial
maxRange Maximum range of your vehicle, it is used in two dial display style to show correct prgoress for range

Possible values: number
Default value: 100
updateInterval Update interval for refreshing the car data in milliseconds

Possible values: number
Default value: 300000 i.e. 5 Minutes
debug Debug mode, used for troubleshooting

Possible values: true or false
Default value: false

Example configuration

modules: [
    {
      module: 'MMM-MercedesMe',
      position: 'bottom_right',
      header: 'My Mercedes',
      config: {
              client_id: '8cebe85d-ca20-486d-ad5f-cf25cae61eeb',
              client_secret: 'VvzJfpOLTZkByzOAqvMcIobgswYulbOeDuTkmhDHAwVjMAOENBGiEkrGWXKkrtYv',
              vehicleType: 'Electric',
              vehicleId: 'WDB111111ZZZ22222',
              displayStyle: 'twodial',
              maxRange: 110
      }
    }
]

After configuring like shown above, run Magic Mirror

  1. It should show you Authenticate link as shown below.

MMM-MercedesMe Screenshot

  1. Click on Authenticate link it should redirect you to login page of Mercedes Me. MMM-MercedesMe Screenshot

  2. It will also show you consent screen for electice or vehicle status based on your vehicle type MMM-MercedesMe Screenshot

  3. Once you click Allow it should redirect back to Magic Mirror and should show you Mercedes Me data based on your display style.

MMM-MercedesMe Screenshot

Dependencies

  • request (available via MM core)
  • fs (available via node.js)

Updating

To update the module to the latest version, use your terminal to go to your MMM-ModuleScheduler module folder and type the following command:

git pull

Troubleshooting

If something is not working, turn on logging by setting the config variable debug to true, and look at the data you receive in dev tools and console of MM.

Bug reports

If you find a bug or have an improvement suggestions, please create a Github issue.

Contributions

Contributions are welcome. Please create a github issue first, so we can dicuss the change before you make it. Create a pull request when you have a change to submit.

Thanks

The MIT License (MIT)

Copyright © 2021 Ashish Tank

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

The software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.