Skip to content

Commit

Permalink
Added optional config to specify what to avoid in calculating time to…
Browse files Browse the repository at this point in the history
… a destination.
  • Loading branch information
jclarke0000 committed May 16, 2017
1 parent 144856b commit c69eed2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions MMM-MyCommute.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ Module.register('MMM-MyCommute', {
'bicycling': 'bike',
'transit': 'streetcar'
},

avoidOptions: [
'tolls',
'highways',
'ferries',
'indoor'
],


start: function() {
Expand Down Expand Up @@ -94,6 +101,9 @@ Module.register('MMM-MyCommute', {
params += '&destination=' + encodeURIComponent(dest.destination);
params += '&key=' + this.config.apikey;
params += '&mode=' + (dest.mode == null || '' ? 'driving' : dest.mode);
if (dest.avoid != null && this.avoidOptions.indexOf(dest.avoid) != -1) {
params += '&avoid=' + dest.avoid;
}
return params;
},

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Each object in the `destinations` array has the following parameters:
|`destination`|**REQUIRED** The address of the destination<br><br>**Type:** `string`|
|`label`|**REQUIRED** How you would like this displayed on your MagicMirror.<br><br>**Type:** `string`|
|`mode`|Transportation mode, one of the following: `driving`, `walking`, `bicycling`, `transit`.<br><br>**Type:** `string`<br>Defaults to `driving`.|
|`avoid`|If specified, will instruct the Google API to find a route that avoids one of the following: `tolls`,`highways`,`ferries`,`indoor`. Any other value will be ignored. Only one option can be specified.|
|`color`|If specified, the colour for the icon in hexadecimal format (e.g.: `"#82BAE5"`)<br><br>**Type:** `string`<br>Defaults to white.|


Expand Down Expand Up @@ -64,7 +65,8 @@ Here is an example of an entry in `config.js`
},
{
destination: '6301 Silver Dart Dr, Mississauga, ON L5P 1B2',
label: 'Pearson Airport'
label: 'Pearson Airport',
avoid: 'tolls'
}
]
}
Expand Down

0 comments on commit c69eed2

Please sign in to comment.