Code Monkey home page Code Monkey logo

mmm-mycommute's Introduction

MMM-MyCommute

This a module for the MagicMirror.

It shows your commute time using Google's Directions API (requires an API Key from Google).

It is a fork of jclarke0000's work

Screenshot

Status

I started this fork because it seems Jeff Clarke has abondoned MMM-MyCommute, no recent updates and not mering PR's. I have merged the interesting changes I've found in other forks.

The module is a bit outdated, doesn't properly install on a new MagicMirror and doesn't live up to its expectations anymore. It's in need of a complete rewrite.

Support MMM-MyCommute rebuild

I'm looking for some moral support to start a complete rebuild.

The rebuild will be fully open source and free of charge.

Feature requests from contributors will be implemented (reasonably).

Donate here: https://gofund.me/b15bc3a0

Forward and share the Gofund.me as you see fit.

Updating

In a recent change the parameter apikey (no capitcal k) was renamed to apiKey (capital K). Please make sure, after updating you apply this change in your config.js too.

Installation

  1. Navigate into your MagicMirror modules folder and execute
    git clone https://github.com/qistoph/MMM-MyCommute.git.
  2. Enter the MMM-MyCommute directory and execute npm install.
  3. Go to Google Maps devtools and get an API key.
  4. Enable Directions API.
  5. NOTE: After the free period you might need to enable billing.
  6. Restart MagicMirror
    e.g. pm2 restart mm

Google Billing

According to the billing information: "you get $200 free usage every month for Maps, Routes, or Places. Based on the millions of users using our APIs today, most of them can continue to use Google Maps Platform for free with this credit."

The default polling time is once every 10 minutes. That would ammount to an average of 4464 requests per month (60 / 10 * 24 * 31 = 4464). For the Directions ($0.005/request) that totals to $22.32 per month. For Advanced Directions ($0.01/request) the total is $44.62 per month.

Advanced Directions are directions that use one or more of:

  • Traffic Information
  • More than 10 waypoints
  • Waypoints optimization

The number of requests can easily be significantly reduced by using the startTime and endTime.

NOTE To those updating from previous verions

You now configure the header in the standard way instead using the headerText and showHeader parameters. So if your config looked like this before:

    {
      module: 'MMM-MyCommute',
      position: 'top_left',
      classes: 'default everyone',
      config: {
        showHeader: true,
        headerText: 'Traffic',
        ...
      }
    }

change it to this:

   {
      module: 'MMM-MyCommute',
      position: 'top_left',
      header: 'Traffic',
      classes: 'default everyone',
      config: {
        ...
      }
    }

If you don’t want a header, then just omit it.

Config

Option Description
apiKey REQUIRED API Key from Google

Type: string
origin REQUIRED The starting point for your commute. Usually this is your home address.

Type: string
This is as you would see it Google Maps. Example: 65 Front St W, Toronto, ON M5J 1E6
startTime The start time of the window during which this module wil be visible.

Type: string
Must be in 24-hour time format. Defaults to 00:00 (i.e.: midnight)
endTime The end time of the window during which this module wil be visible.

Type: string
Must be in 24-hour time format. Defaults to 23:59 (i.e.: one minute before midnight).
hideDays A list of numbers representing days of the week to hide the module.

Type: array
Valid numbers are 0 through 6, 0 = Sunday, 6 = Saturday.
e.g.: [0,6] hides the module on weekends.
showSummary Whether to show a brief summary of the route

Type: boolean
Defaults to true
showUpdated Show when the last update completed

Type: boolean
Default to true
showUpdatedPosition Position where to show last update completed. Valid options are header or footer.

Type: string
Default to footer
colorCodeTravelTime Whether to colour-code the travel time red, yellow, or green based on traffic.

Type: boolean
Defaults to true
travelTimeFormat How the module should format your total travel time.

Type: string
Defaults to m [min] (e.g. 86 min). Some other examples are h[h] m[m] (e.g.: 1h 26min), h:mm (e.g. 1:26). This uses the moment-duration-format plugin's templating feature.
travelTimeFormatTrim How to handle time tokens that have no value. For example, if you configure travelTimeFormat as "hh:mm" but the actual travel time is less than an hour, by default only the minute portion of the duration will be rendered. Set travelTimeFormatTrim to false to preserve the hh: portion of the format (e.g.: 00:21). Valid options are "left", "right" (e.g.: 2:00 renders as 2), or false (e.g.: do not trim).

Type: String or false
Defaults to "left".
moderateTimeThreshold The amount of variance between time in traffic vs absolute fastest time after which the time is coloured yellow

Type: float
Defaults to 1.1 (i.e.: 10% longer than fastest time)
poorTimeThreshold The amount of variance between time in traffic vs absolute fastest time after which the time is coloured red

Type: float
Defaults to 1.3 (i.e.: 30% longer than fastest time)
nextTransitVehicleDepartureFormat For any transit destinations where showNextVehicleDeparture is true, this dictates how to format the next arrival time.

Type: string
Defaults to [next at] h:mm a.
pollFrequency How frequently, in milliseconds, to poll for traffic predictions.
BE CAREFUL WITH THIS! We're using Google's free API which has a maximum of 2400 requests per day. Each entry in the destinations list requires its own request so if you set this to be too frequent, it's pretty easy to blow your request quota.

Type: number.
Defaults to 10 * 60 * 1000 (i.e.: 600000ms, or every 10 minutes)
destinations An array of destinations to which you would like to see commute times.

Type: array of objects.
See below for destination options.
showError Hides error message if false and renders the last result. This is meant to bypass short issues like a lost WiFi signal.

Type: boolean
Default to true

Each object in the destinations array can have the following parameters:

Option Description
destination REQUIRED The address of the destination

Type: string
label REQUIRED How you would like this displayed on your MagicMirror.

Type: string
mode Transportation mode, one of the following: driving, walking, bicycling, transit.

Type: string
Defaults to driving.
transitMode If mode = transit you can additionally specify one or more of the following: bus, subway, train, tram, or rail.

Type: string.
Separate multiple entries with the | character (e.g.: "transitMode" : "bus|subway|tram"). Specifying railindicates that the calculated route should prefer travel by train, tram, light rail, and subway. Equivalenet to train|tram|subway
showNextVehicleDeparture If mode = transit the time of the next departure of the first vehicle on your route will be displayed in the route summary. Only visible when showSummary = true.

Type: boolean.
waypoints If specified, it instructs Google to find the route that passes through the waypoints you specify.

Type: string.
Separate multiple entries with the | character. See Waypoints docs for details on how waypoints can be specified.
NOTE: your waypoints will automatically be prefixed with via: so that they are not treated as stopovers. This can cause Google to plan an erratic route. if you find your time predictions are wildly overestimated, then try adjusting your waypoints. Intersections where you would normally make a turn on this roite usually work well (e.g.: Main St & Southwood Drive Toronto ON).
avoid If specified, will instruct the Google API to find a route that avoids one or more of the following: tolls,highways,ferries,indoor.

Type: string.
Separate multiple entries with the | character (e.g.: "avoid" : "highways|tolls").
alternatives If specified, will instruct the Google API to provide times for alternate routes. Must be used with showSummary: true

Type: boolean
color If specified, the colour for the icon in hexadecimal format (e.g.: "#82BAE5")

Type: string
Defaults to white.
startTime The start time of the window during which this destination wil be visible.

Type: string
Must be in 24-hour time format. Defaults to 00:00 (i.e.: midnight)
endTime The end time of the window during which this destination wil be visible.

Type: string
Must be in 24-hour time format. Defaults to 23:59 (i.e.: one minute before midnight).
hideDays A list of numbers representing days of the week to hide the destination.

Type: array
Valid numbers are 0 through 6, 0 = Sunday, 6 = Saturday.
e.g.: [0,6] hides the destination on weekends.
origin Optionally overide the global origin for a single destination.

Here is an example of an entry in config.js

{
  module: 'MMM-MyCommute',
  position: 'top_left',
  config: {
    apiKey: 'API_KEY_FROM_GOOGLE',
    origin: '65 Front St W, Toronto, ON M5J 1E6',
    startTime: '00:00',
    endTime: '23:59',
    hideDays: [0,6],
    destinations: [
      {
        destination: '14 Duncan St Toronto, ON M5H 3G8',
        label: 'Air Canada Centre',
        mode: 'walking',
        color: '#82E5AA'
      },
      {
        destination: '317 Dundas St W, Toronto, ON M5T 1G4',
        label: 'Art Gallery of Ontario',
        mode: 'transit'
      },
      {
        destination: '55 Mill St, Toronto, ON M5A 3C4',
        label: 'Distillery District',
        mode: 'bicycling'
      },
      {
        destination: '6301 Silver Dart Dr, Mississauga, ON L5P 1B2',
        label: 'Pearson Airport',
        avoid: 'tolls'
      }
    ]
  }
}

Routes for calendar events

Additionally MMM-MyCommute can show travel times to upcoming events in the default calendar module. The config can be extended with the following options. Routes will be shown for events with a location.

Option Description
maxCalendarEvents Number of routes to show.

Type: int
Defaults to 0
maxCalendarTime Show routes only for appointments within this timeframe (in milliseconds).

Type: int
Defaults to 24 * 60 * 60 * 1000 (1 day)
calendarOptions An array like the regular destinations. For each event all of these options are added as a route. All options from above can be used, except that label will be overwritten with the event subject and destination with the event location. maxLabelLength can be used to trim topics of appointments.

Type: array
Defaults to [{mode: 'driving', maxLabelLength: 25}]

Here is an example of an entry in config.js including calendar event routes

{
  module: 'MMM-MyCommute',
  position: 'top_left',
  config: {
    apiKey: 'API_KEY_FROM_GOOGLE',
    origin: '65 Front St W, Toronto, ON M5J 1E6',
    destinations: [
      {
        destination: '14 Duncan St Toronto, ON M5H 3G8',
        label: 'Air Canada Centre',
        mode: 'walking',
        color: '#82E5AA'
      }
    ],
    // Additional config for calendar routes:
    maxCalendarEvents: 2,
    calendarOptions: [
      {
        mode: 'driving'
      },
      {
        mode: 'transit',
        transitMode: 'train'
      }
    ]
  }
}

Troubleshooting

If the module seems to malfunction or doesn't show any route information at all, here are some guidelines to help you fix it:

  • Check the server side log of MagicMirror
  • Check the client side log of your mirror
  • Check the known issues
  • Create a new issue, including a clear description of your problem and the relevant server and client logs

Dependencies

Installed during installation

Special Thanks

  • Jeff Clarke for creating MMM-MyCommute, this has inspired all my additional changes.
  • Michael Teeuw for creating the awesome MagicMirror2 project that made this module possible.
  • Dominic Marx for creating the original mrx-work-traffic that this module heavily borrows upon.

mmm-mycommute's People

Contributors

aaronpk avatar bilbolodz avatar domsen123 avatar handwrittenjello avatar jclarke0000 avatar knurlnheim avatar qistoph avatar radokristof avatar theduffman85 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mmm-mycommute's Issues

Issues with startTime / endTime

For me the startTime / endTime parameter won't work and i cant figure out what is the issue behind. Other modules don't look that nice as MyCommute and don't offer this amount of functions so I hope that somebody out there is able to support me and may fix my issue that i could keep it.

If I restart MagicMirror in the time period when a route is configured (e.g. weekdays at 7am) it will be shown accordantly and also disappear automatically as configured. But afterwards e.g. on the next morning the module will never show up again as configured. I checked pm2 logs and also the developer tools (crtl + shift + i) but cant see any issues.

If i force a reload with ctrl + shift + r in the morning when a route is configured the module is also loaded and shown as expected.

But it never shows up again automatically...

The used configuration looks as follow:

    disabled: false,
    module: 'MMM-MyCommute',
    position: 'top_right',
			header: 'Fahrzeit',
			classes: 'default everyone',
			config: {
				apikey: 'my api',
			    	origin: 'my address',
			    	//startTime: '00:00',
			    	//endTime: '23:59',
			    	//hideDays: [0,6],
			   	showSummary: true,
			   	colorCodeTravelTime: true,
				nextTransitVehicleDepartureFormat: '[um] HH:mm',
			   	destinations: [
			     	 	{
			       		destination: 'destination1',
			        	label: 'label1',
			        	mode: 'transit',
						showNextVehicleDeparture: true,
						color: '#ffcc33',
						startTime: '05:30',
			    		        endTime: '06:30',
						hideDays: [0,6],
						},
			      		{
				        destination: 'destination2',
				        label: 'label2',
				        mode: 'driving',
						alternatives: true,
						startTime: '06:30',
			    		        endTime: '08:00',
						hideDays: [0,6],
						},
			      		{
				        destination: 'destination3',
				        label: 'label3',
			        	mode: 'transit',
						showNextVehicleDeparture: true,
						color: '#ffcc33',
						startTime: '06:00',
			    		        endTime: '08:00',
						hideDays: [0,6],
						},
			     ]
			  }
		},

Output of developer tools:

Load script: modules/MMM-MyCommute//MMM-MyCommute.js
module.js:477 Module registered: MMM-MyCommute
loader.js:152 Bootstrapping module: MMM-MyCommute
loader.js:182 Load script: modules/MMM-MyCommute/node_modules/moment-duration-format/lib/moment-duration-format.js
loader.js:157 Scripts loaded for: MMM-MyCommute
loader.js:197 Load stylesheet: modules/MMM-MyCommute/MMM-MyCommute.css
loader.js:159 Styles loaded for: MMM-MyCommute
loader.js:161 Translations loaded for: MMM-MyCommute
MMM-MyCommute.js:125 Starting module: MMM-MyCommute
3 MMM-MyCommute.js:248 MMM-MyCommute refreshing routes
MMM-MyCommute.js:153 MMM-MyCommute suspended

During writing this issue i found the following output of pm2 logs but not quite sure if its related to MyCommute due to missing time stamp.

0|MagicMirror  | (node:5349) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'hash' of null
0|MagicMirror  | (node:5349) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Cheers
Timo

Bug: No longer works with MM 2.20 and can't add request module

Describe the bug
MMM-MyCommute will no longer start, and shows error.

To Reproduce
Steps to reproduce the behavior:

  1. Old install of MagicMirror with MMM-MyCommute module active
  2. Upgrade to MM 2.20
  3. Restart MagicMirror
  4. Black screen

Expected behavior
It should show as normal.

Screenshots

Running version

Additional context

-
    at Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
    at n._resolveFilename (node:electron/js2c/browser_init:245:1105)
    at Module._resolveFilename (/home/pi/MagicMirror/node_modules/module-alias/index.js:49:29)
    at Module._load (node:internal/modules/cjs/loader:785:27)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/pi/MagicMirror/modules/MMM-MyCommute/node_helper.js:9:17)
    at Module._compile (node:internal/modules/cjs/loader:1118:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
[31.08.2022 06:55.06.806] [ERROR] Whoops! There was an uncaught exception...
[31.08.2022 06:55.06.822] [ERROR] Error: Cannot find module 'request'
Require stack:
- /home/pi/MagicMirror/modules/MMM-MyCommute/node_helper.js
- /home/pi/MagicMirror/js/app.js
- /home/pi/MagicMirror/js/electron.js
- /home/pi/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js
-
    at Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
    at n._resolveFilename (node:electron/js2c/browser_init:245:1105)
    at Module._resolveFilename (/home/pi/MagicMirror/node_modules/module-alias/index.js:49:29)
    at Module._load (node:internal/modules/cjs/loader:785:27)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/pi/MagicMirror/modules/MMM-MyCommute/node_helper.js:9:17)
    at Module._compile (node:internal/modules/cjs/loader:1118:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/pi/MagicMirror/modules/MMM-MyCommute/node_helper.js',
    '/home/pi/MagicMirror/js/app.js',
    '/home/pi/MagicMirror/js/electron.js',
    '/home/pi/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js',
    undefined
  ]
}

I tried installing request module, but that also errored out:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/stylelint
npm ERR!   dev stylelint@"^9.10.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer stylelint@"^13.8.0" from [email protected]
npm ERR! node_modules/grunt-stylelint
npm ERR!   dev grunt-stylelint@"^0.16.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/pi/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2022-08-31T08_36_52_542Z-debug-0.log

Bug: Module doesn't show up

----Nevemind!-----

Hi!

I had a working MagicMirror up until 2 days ago. It worked perfect including the MMM-MyCommute module.

Yesterday and today the MMM-MyCommute module isn't showing anymore. Other modules are still working. I have tested with a clean install on a different pi, with the example config.js from MagicMirror² and only the MMM-MyCommute module enabled but without any luck.

I do not see any errors in the console logging within the terminal after hitting npm start from cd MagicMirror.

I have revoked all limitations on my Google API for Directions (190 hits this month, had my magicmirror installed first 7 days ago but did not have it turned on all day every day) but that did not help either.

I would have expected the header to show up in MagicMirror and somethin like "loading" but I can not see anything that is related to MMM-MyCommute wihtin MagicMirror itself or log files.

Below is my code. Can anyone help me with this strange issue?

`/* Magic Mirror Config Sample
*

*/

var config = {
address: "localhost", // Address to listen on, can be:
// - "localhost", "127.0.0.1", "::1" to listen on loopback interface
// - another specific IPv4/6 to listen on a specific interface
// - "0.0.0.0", "::" to listen on any interface
// Default, when address config is left out or empty, is "localhost"
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], // Set [] to allow all IP addresses
// or add a specific IPv4 of 192.168.1.5 :
// ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"],
// or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format :
// ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"],

useHttps: false, 		// Support HTTPS or not, default "false" will use HTTP
httpsPrivateKey: "", 	// HTTPS private key path, only require when useHttps is true
httpsCertificate: "", 	// HTTPS Certificate path, only require when useHttps is true

language: "en",
timeFormat: 24,
units: "metric",
// serverOnly:  true/false/"local" ,
// local for armv6l processors, default
//   starts serveronly and then starts chrome browser
// false, default for all  NON-armv6l devices
// true, force serveronly mode, because you want to.. no UI on this device

modules: [
	{
		module: "alert",
	},
	{
		module: "updatenotification",
		position: "top_bar"
	},
	{
		module: "clock",
		position: "top_left"
	},
	{
		module: "calendar",
		header: "US Holidays",
		position: "top_left",
		config: {
			calendars: [
				{
					symbol: "calendar-check",
					url: "webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics"
				}
			]
		}
	},
	{
		module: "compliments",
		position: "lower_third"
	},
	{
		module: "currentweather",
		position: "top_right",
		config: {
			location: "New York",
			locationID: "", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
			appid: "YOUR_OPENWEATHER_API_KEY"
		}
	},
	{
		module: "weatherforecast",
		position: "top_right",
		header: "Weather Forecast",
		config: {
			location: "New York",
			locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
			appid: "YOUR_OPENWEATHER_API_KEY"
		}
	},
	{
		module: "newsfeed",
		position: "bottom_bar",
		config: {
			feeds: [
				{
					title: "New York Times",
					url: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml"
				}
			],
			showSourceTitle: true,
			showPublishDate: true,
			broadcastNewsFeeds: true,
			broadcastNewsUpdates: true
		}
	},
	{
		module: "MMM-MyCommute",
		header: "TravelTimes",
		position: "top_left",
		config: {
			apiKey: "MyApiKey",
			origin: "65 Front St W, Toronto, ON M5J 1E6",
			startTime: "00:00",
			endTime: "23:59",
			hideDays: [0, 6],
			destinations: [
				{
					destination: "14 Duncan St Toronto, ON M5H 3G8",
					label: "Air Canada Centre",
					mode: "walking",
					color: "#82E5AA"
				},
				{
					destination: "317 Dundas St W, Toronto, ON M5T 1G4",
					label: "Art Gallery of Ontario",
					mode: "transit"
				},
				{
					destination: "55 Mill St, Toronto, ON M5A 3C4",
					label: "Distillery District",
					mode: "bicycling"
				},
				{
					destination: "6301 Silver Dart Dr, Mississauga, ON L5P 1B2",
					label: "Pearson Airport",
					avoid: "tolls"
				}
			]
		}
	}
]

};

/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") { module.exports = config; }
`

Can someone help me with my adresses?

Hey guys im totally new to this and im trying to get this working. I managed to get the module on the screen it shows loading indefinetly i think i just put the adresses wrong, i really dont know how to add it there. if someone can help me how to formulate it i would really appreciate it!

Adress 1: https://goo.gl/maps/aRcCEetg3f11dZUo9
Adress 2: https://goo.gl/maps/qZD1SWUr3DP8QApa9
Origin Adress: https://goo.gl/maps/KG1BzbZwxAZfNpds7
i tried from origin adress to way on 1 like this:
{ module: 'MMM-MyCommute', position: 'top_right', header: 'MHD', classes: 'default everyone', config: { apiKey: 'MY API KEY', origin: 'Raketová 1472/1, Košice, 040 12', startTime: '00:00', endTime: '23:59', hideDays: [], destinations: [ { destination: "Námestie osloboditeľov 3377/1, Košice, 040 01", label: "Mesto", mode: "transit", time: null }, ]

Bug: startTime delayed (max pollFrequency)

An update cycle is run periodically (see pollFrequency). The module is only shown if during this update cycle the current time is between startTime and endTime.

It would be better if the module would be shown as soon as the current time reaches startTime.

Bug: Heavy use of API calls

Copy of my posting found here:
https://forum.magicmirror.builders/topic/2555/mmm-mycommute/266?page=27

Okay, played around a bit. Set the module to show times only from 5am to 5pm. And I added a “pollFrequency: 15 * 60 * 1000,” to my config.
While the first one works (the module disappears at night), the second one does not seem to work:

grafik

This is the Traffic from the last 2 days. You can see the requests are paused last night. I made changes to the poll frequency yesterday in the afternoon, no change.

The module used up nearly all of my €300 starting balance. I wonder if this will go on like this.

API calls in the last 48 hours:
grafik

API calls in the last ONE hour:

grafik

Which I do not understand: No errors. Poll Frequency of every 15 Minutes. 2 Mirrors with 4 destinations each. So 4*8=24 API calls/hour would be what I expect to see…

Google API error

Hello,

I always get this error: Error: You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account

I have billing enabled on my google account as well as the Directions API. It worked before I updated my MM and reinstalled this plugin. Any ideas why this is not working? I also created a new project and new API keys multiple times but no luck either.

Thanks!

Feature: Poll on inital refresh

I am finding that until the first time pollFrequency is engaged, it is not showing my calendar events.

Is there a way to have it refresh early on say 30 seconds after, then keep on going on every pollFrequency?

Just as my display turns on, it refreshes everything.

How to troubleshoot/ Error shown on driving time

Hi,

First, thanks for maintaining this module - this is quite useful for my morning drive.

I'm having an issue where the drive time on Magic Mirror is showing "Error." As in, I see my label for my destination, followed by the red "Error" text for the drive time. I've check the address with maps.google.com and it exists; it'll show the travel time. I've logged into the google cloud platform and I've enabled Maps Javascript API, Directions API, and Geocoding API.

Whenever I load up Magic Mirror, I can see the error counts show up in the google cloud dashboard, so I know the apiKey is working.

Whats the best way to start diagnosing the problem? Is there any way to see the error message generated? I'm familiar with Java (but not JavaScript). I've tried tracing the MyCommute code down to line 462, where the ERROR message is set, but I don't know exactly what the error message is.

Any help is most appreciated.

module disappears

It seems that approximately once per day, the module will completely disappear. No error messages appear in the PM2 log files mm-out.log or mm-error.log. Restarting my magicmirror always brings it back, only for it to disappear the next day.

What is causing this? How can I figure out the cause?

Feature: Mutiple values for start time, end time

Feature request:

I am "wait to the last minute" person. Which means for traffic reports, I like to have the most up-to-date time to arrive to my school/work/etc exactly on time.

" A wizard is never late, nor is he early, he arrives precisely when he means to."

I also do not want to exhaust my limited google maps requests. Which means I would like two (or more) start time/end times. Basically, during rush hour (or school hours) is when I want up to the minute refreshes.

Is there a way to change the startTime/endTime parameter to have multiple start time, end times. For example,
startTime: '06:00', '17:00'
endTime: '07:59', '18:00'
which means that the mirror updates at 6am - 7:59a, and again at 17:00-18:00.

Of course, this is a nice to have feature. Can you put the start times into an array?

Thanks

Feature: arrival time and/or time until departure dependent upon calendar

2 ideas for improvement. If I knew how to code I would love to work on this but I am new to code and am currently learning intro to cs now!

1.) include a feature to add commute time and current time to show arrival time if leaving NOW.

2.) Include a feature that uses calendar event time minus current commute time equal to departure time for on-time arrival (also include a way to move the time by 60 mins one way or another, to allow for early meeting arrival)

thanks for your amazing work!

Feature: calculate arrival time between updates

The arrival time is currently only refreshed on interval updates.

An interesting idea mentioned in issue #17 is to calculate an up to date arrival time more often.

Thinks to take into account:
(suggestions welcome in comments)

  • won't work for commutes with public transport
  • maybe directions offers multiple replies for public transport that we can cache for a few minutes

Bug: Display of asian addresses

Describe the bug
Module displays "loading" for asian addresses.
Google maps api console shows successful api calls with code 200.

Running version
Hash of the version you're using:
55d407bb51db0561d8c9be0f2e548c1b85b782a6

Additional context
Default settings and config work as expected. Overall fantastic module, and I'd love to use it.

{
  module: 'MMM-MyCommute',
  position: 'bottom_left',
  config: {
    apikey: 'correct api key, code 200 on maps console',
    origin: '東京都新宿区市谷加賀町2丁目3 CENTLAY ICHIGAYA',
    startTime: '06:00',
    endTime: '21:59',
    destinations: [
      {
        destination: 'Kojimachi Station, 4丁目 麹町 千代田区 東京都',
        label: 'Kojimachi Station',
        mode: 'transit',
        color: '#82E5AA'
      },
      {
        destination: 'Shinjuku Station, 3丁目-38 新宿 新宿区 東京都',
        label: 'Shinjuku Station',
        mode: 'transit'
      },
    ]
  }
},

Bug: cant get alternative routes just gives 1

 module: 'MMM-MyCommute',
                         position: 'top_left',
                         config: {
                         apikey: '',
                         origin: '',
                         startTime: '00:00',
                         endTime: '23:59',
                         hideDays: [0,6],
                         showSummary: true,
                         destinations: [
                                {
                                  destination: '',
                                  label: '',
                                  mode: 'driving',
                                  color: '#82E5AA',
                                  alternatives: true,
                                 }
                               ]
                            }

no idea where im going wrong any help would be appreciated

Issues with startTime / endTime

The issue is still present for me. If I set the endTime to midnight the module hides, but never returns at 06:00 am automatically, I always have to restart MM so that the module appears again. I've tested with different random times with no success.

I've set both in config.js. Changing settings in MMM-MyCommute.js makes no difference. (I know this is not advised, but anyways I wanted to troubleshoot this)

After doing git pull; npm install
pi@raspberrypi:~/MagicMirror/modules/MMM-MyCommute $ git rev-parse HEAD e9a13ba0d7b94ca9f7161f420e86d16cea514fa8
I did try several complete reboots with different start and end times this still has not worked for me.
Any ideas how to fix this?
Please note, hideDays is not configured. And of course I've read through Issue#1 but it did not resolve the issue for me.
Thank you!

Bug: Update Description

Reading from previously open issues, a few suggestions to help:

Under initial description, update "Google's Traffic API" to "Google's Directions API" and hyperlink to API (https://console.cloud.google.com/marketplace/details/google/directions-backend.googleapis.com?folder=&organizationId=&project=arboreal-pen-251823).

Under Installation, modify point 3 to include "Go to Google Maps devtools, get an API key, and enable Directions API from library". Add a note that if you receive an ERROR in the MagicMirror application, that the user may need to verify a Billing Account has been added under for the API project in Google Cloud Platform. Or link directions on how to get started with Google's API projects.

Thanks!

Calendar events are not being added if you specify transit

Calendar events are not being added because the arrival time passed to the google API is the timestamp in miliseconds. (example: arrival_time=1584806232000)

When doing the request with the epoch timestamp which does not include miliseconds the request succeeds (example: arrival_time=1584806232)

Google dev guide states:

arrival_time — Specifies the desired time of arrival for transit directions, in seconds since midnight, January 1, 1970 UTC. You can specify either departure_time or arrival_time, but not both. Note that arrival_time must be specified as an integer.

I've fixed this by deviding calendar event times by 1000
arrival_time: calendarEvent.startDate/1000

Unclear if it breaks anything else by doing so, will post if so.

Bug: Not Making API requests

Describe the bug
The module displays "Error" in red where the commute times should be. I checked my Maps JavaScript API and it does not show any API requests being made by the module.

To Reproduce

  1. Format the config.js for the MagicMirror as follows (replacing the destinations and the API key):
{
  module: 'MMM-MyCommute',
  position: 'top_left',
  config: {
    apikey: 'API_KEY_FROM_GOOGLE',
    origin: '65 Front St W, Toronto, ON M5J 1E6',
    startTime: '00:00',
    endTime: '23:59',
    hideDays: [0,6],
    destinations: [
      {
        destination: '14 Duncan St Toronto, ON M5H 3G8',
        label: 'Air Canada Centre',
        mode: 'walking',
        color: '#82E5AA'
      },
      {
        destination: '317 Dundas St W, Toronto, ON M5T 1G4',
        label: 'Art Gallery of Ontario',
        mode: 'transit'
      },
      {
        destination: '55 Mill St, Toronto, ON M5A 3C4',
        label: 'Distillery District',
        mode: 'bicycling'
      },
      {
        destination: '6301 Silver Dart Dr, Mississauga, ON L5P 1B2',
        label: 'Pearson Airport',
        avoid: 'tolls'
      }
    ]
  }
}
  1. Restart the MagicMirror (pm2 restart mm)
  2. Wait for the module to load and display the error message

Expected behavior
Expected to see commute times to the right of the destination names.

Screenshots
IMG_14341_20190724_224558

Screenshot_4

Running version
I am running the most recent commit (May 20). I will include the hash when I get a chance.

Additional context
I used this module in the past (roughly one year ago) without issue. I just recently started using my MagicMirror again and noticed Google Cloud Platform organizes the various APIs differently. It is possible that the issue is due to the changes in the API, I am using the Maps JavaScript API since it was not 100% clear which API is to be used.

Calendar Events not displaying

I’m using Apple’s public iCal to broadcast events synced to my iCloud. However, when I add events with Location, it doesn’t provide me travel time to destination.

{ module: 'MMM-MyCommute', position: 'top_left', header: 'Commute', config: { apiKey: 'hidden', origin: 'hidden', startTime: '04:00', endTime: '22:00', maxCalendarEvents: 3, destinations: [ { destination: 'addr1', label: 'Study', mode: 'walking', color: '#ff1990', hideDays: [0,6] }, { destination: 'Addr2', label: 'Hidden', color: '#fa4848' } ] } },

Bug: Insane amount of request made to the Advanced Directions Api

Describe the bug
Insane amounts of request, but like 200 000 requests per month insane. My poll frequency is 10 minutes, yet on my Google Cloud Platform I see 4000 requests for Directions Api and 200 000 requests for Advanced Directions Api.

To Reproduce
I setup my Magic Mirror by having the server on a Ubuntu VM and I display it on a Raspberry Pi 0 on Chromium. Can't really help much more. I have no waypoints setuped but I do use traffic infos.

Expected behavior
Make a request every 10 minutes.

Running version
Lastest
6723883

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.