Skip to content

MagicMirror module that shows the best routes from A to B

License

Notifications You must be signed in to change notification settings

Paranoid93/MMM-google-route

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MMM-google-route

Alt text

A module for the MagicMirror² that displays the two best routes from an origin to a destination, using Google Directions API.

Using the module

To use this module, clone this repo to your MagicMirror/modules/ directory.

git clone https://github.com/mrdis/MMM-google-route.git

And add the following configuration block to the modules array in the config/config.js file:

var config = {
    modules: [

        {
            module: 'MMM-google-route',
            position: 'top_left',
            config: {
                key: '<YOUR_KEY>',
                directionsRequest:{
                    origin: '<ROUTE START>',
                    destination: '<ROUTE FINISH>'
                }
            }
        }

    ]
}

Configuration options

Option Description
key Required Google api key. See below for help.
Type: string
directionsRequest Required The directions to show on the map.
Type: google.maps.DirectionsRequest interface
language Directions language
Type: string
Default value: en
title Optional title to show above the map.
Type: string
height Height of the map.
Type: string (pixels)
Default value: 300px
width Width of the map.
Type: string (pixels)
Default value: 300px
refreshPeriod Period between API requests. Set to 0 to disable periodic refresh.
Type: integer (minutes)
Default value: 1
 minimumRefreshPeriod Set a minimum period between API requests. This is useful when used in combination with listen.
Type: integer (minutes)
Default value: 0
showAge Show how long ago the routes were updated.
Type: boolean
Default value: true
showMap Show the map.
Type: boolean
Default value: true
fontSize Size of the title and routes font. Use a percentage to specify size relative to default.
HTML DOM Style fontSize property
Type: string
Default value: 100%
mapOptions Map visualization options.
Type: google.maps.MapOptions interface
listen Refresh the route when receiving these notifications and use the location contained in the notification as destination (if available).
Specify the ID of the notifications to listen for.
Type: string[]
Default value: []

Google API Key

Obtain an api key at Google Developer's page.

Google directions service errors

If "Google directions service status:" error message appears, it means that the request to the Google directions service failed for some reason.

The list of error codes and their meanings can be found here.

Importance of correct date/time settings

If "Google directions service status: INVALID_REQUEST" error message appears, it could be due to an invalid setting of the current date and time on the device that is displaying the mirror interface.

This is due to the departureTime field of the drivingOptions field passed to the directions API being set to one minute from the current time, and google service checking that this timestamp is in the future.

Using MMM-ModuleScheduler to configure the route refresh interval

You can use the MMM-ModuleScheduler module to trigger route updates using a certain schedule.
This may be useful for example to refresh the route more frequently in the morning and less frequently during the rest of the day, reducing the risk of exceeding the query limit set by google.

Just set "MMM-google-route/refresh" as the notification id in the notification_schedule configuration parameter of the module, e.g.

    {
        module: 'MMM-ModuleScheduler',
        config: {
            notification_schedule: [
                // Refresh the route every minute from 7:00 AM to 8:00 AM, monday to friday
                { notification: 'MMM-google-route/refresh', schedule: '* 7 * * 1-5' }
            ]
        }
    },

Notifications supported as destination providers

CALENDAR_EVENTS

The first valid location field of the events contained in the notification payload will be used as destination.

About

MagicMirror module that shows the best routes from A to B

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%