qistoph / MMM-MyCommute

This a module for the MagicMirror. It shows your commute time using Google's Traffic API
39 stars 14 forks source link

Issues with startTime / endTime #1

Closed TimoBS closed 5 years ago

TimoBS commented 5 years ago

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

qistoph commented 5 years ago

Could you please add the hash of the commit you're running?

$ cd modules/MMM-MyCommute
$ git rev-parse HEAD

It should look like a hexadecimal string, such as cbad3fb1f6953a5e0719e938d9844cccfcdc4881.

TimoBS commented 5 years ago

Wow... very fast response. Many thanks in advance.

My hash seems to be equal:

pi@mirrorpi:~/MagicMirror/modules/MMM-MyCommute $ git rev-parse HEAD
cbad3fb1f6953a5e0719e938d9844cccfcdc4881
qistoph commented 5 years ago

I think I've found the bug...

Would this description meet the issue you're experiencing?

qistoph commented 5 years ago

Just pushed some code changes that I think will fix this issue. Please re-open if you're still experiencing this problem.

Edit: after updating, ofcourse.

TimoBS commented 5 years ago

Thank you, I‘ll check it and let you know. Regarding your previous post: actually the module is hidden on Saturday and Sundays by hideDays: [0,6] and I‘m facing the issue not only from Sunday to Monday but also within weekdays as e.g. Wednesday to Thursday.

TimoBS commented 5 years ago

Re-open is not offered to me because you as owner did close the issue.

Today I had the chance to re-check and for me the startTime does still not work also with updated module. Actual hash is

~/MagicMirror/modules/MMM-MyCommute $ git rev-parse HEAD
3f78b8224fc03a56bdf913240b96f1b6a0377fae

I had in addition another try by change hideDays: [0,6] to hideDays: [] but also this does not fix it.

Does the parameter startTime working for somebody else or I'm the only one have issues with it?

qistoph commented 5 years ago

Please try another git pull; npm install and let me know if it works

TimoBS commented 5 years ago

In a first test the 2nd try with hash 416fdf4a27bae18d5d732d62f2461cb39775bd46 running on MM 2.7.1 works successful! Module is resumed and also suspend with my configuration below.

{
            disabled: false,
            module: 'MMM-MyCommute',
            position: 'top_right',
            header: 'Fahrzeit',
            classes: 'default everyone',
            config: {
                apikey: '...',
                    origin: '...',
                    //startTime: '14:35',
                    //endTime: '14:45',
                    //hideDays: [0,6],
                showSummary: true,
                colorCodeTravelTime: true,
                nextTransitVehicleDepartureFormat: '[um] HH:mm',
                pollFrequency: 10 * 60 * 1000,
                destinations: [
                        {
                        destination: 'dest1',
                        label: 'label1',
                        mode: 'transit',
                    showNextVehicleDeparture: true,
                    color: '#b20f26',
                    startTime: '15:00',
                        endTime: '15:25',
                    hideDays: [0,6],
                    },
                        {
                        destination: 'dest2',
                        label: 'label2',
                        mode: 'driving',
                    alternatives: true,
                    color: '#4c3fff',
                    startTime: '15:15',
                        endTime: '15:45',
                    hideDays: [0,6],
                    },
                        {
                        destination: 'dest3',
                        label: 'label3',
                        mode: 'transit',
                    showNextVehicleDeparture: true,
                    color: '#00908e',
                    startTime: '15:05',
                        endTime: '16:00',
                    hideDays: [0,6],
                    },
                 ]
              }
        },

Output of developer tool filtered by keyword "mycommute":

MMM-MyCommute refreshing routes :8080/modules/MMM-My…MM-MyCommute.js:239 
MMM-MyCommute resumed :8080/modules/MMM-My…MM-MyCommute.js:160 
2  MMM-MyCommute refreshing routes MMM-MyCommute.js:239 
MMM-MyCommute refreshing routes MMM-MyCommute.js:239 
4 MMM-MyCommute refreshing routes MMM-MyCommute.js:239 
MMM-MyCommute refreshing routes  MMM-MyCommute.js:239 
5 MMM-MyCommute refreshing routes MMM-MyCommute.js:239
MMM-MyCommute refreshing routes  MMM-MyCommute.js:239 
4 MMM-MyCommute refreshing routes MMM-MyCommute.js:239
MMM-MyCommute refreshing routes  MMM-MyCommute.js:239 
4 MMM-MyCommute refreshing routes MMM-MyCommute.js:239
MMM-MyCommute refreshing routes  MMM-MyCommute.js:239 
4 MMM-MyCommute refreshing routes MMM-MyCommute.js:239
MMM-MyCommute refreshing routes  MMM-MyCommute.js:239 
MMM-MyCommute refreshing routes  MMM-MyCommute.js:239 
MMM-MyCommute suspended MMM-MyCommute.js:155 

What I observed but may be not related to this module that if its configured to resume e.g. at 15.00h its mostly not exactly resumed at this time as configured. Seems there is a general cyclic refresh of approx. 5min by MM when all modules are refreshed. When this happens module MMM-MyCommute is also resumed. I think this is not really an issue but good to know.

Output of developer tool at cyclic refresh of MM:

module.js:154 clock received a module notification: CURRENTWEATHER_DATA from sender: currentweather
module.js:154 MMM-DWD-WarnWeather received a module notification: CURRENTWEATHER_DATA from sender: currentweather
module.js:154 calendar received a module notification: CURRENTWEATHER_DATA from sender: currentweather
module.js:154 MMM-PublicTransportHafas received a module notification: CURRENTWEATHER_DATA from sender: currentweather
module.js:154 MMM-PaprikaMenu received a module notification: CURRENTWEATHER_DATA from sender: currentweather
:8080/modules/default/newsfeed//newsfeed.js:344 newsfeed - received notification: CURRENTWEATHER_DATA
:8080/modules/default/newsfeed//newsfeed.js:403 newsfeed - unknown notification, ignoring: CURRENTWEATHER_DATA
module.js:154 MMM-GoogleMapsTraffic received a module notification: CURRENTWEATHER_DATA from sender: currentweather
:8080/modules/MMM-MyCommute//MMM-MyCommute.js:160 MMM-MyCommute resumed
module.js:205 weatherforecast is resumed.

Good work! Thank you qistoph!

qistoph commented 5 years ago

You are correct about the startTime and the timeout before it's actually shown.

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.

I'll create an additional issue to remind myself to look into an update for that some time.