ianperrin / MMM-ModuleScheduler

A MagicMirror helper module to schedule the display of modules and sending of notifications.
MIT License
101 stars 13 forks source link

Trying To Use This Module With MMM-Google-Route. Could use some help #19

Closed dxfan227 closed 5 years ago

dxfan227 commented 5 years ago

So I'm trying to use this to refresh google route at certain times more than others in an effort to reduce API calls/ COST, but I am very new to everything and having trouble understanding a few points. The first is the cron timing..... I want my the route to update every 5 min between 6 AM and 11 AM.....would this be the correct cron info

this is the cron date I have come up with 5,10,15,20,25,30,35,40,50,55 6-11 *

Also on the MMM Google Route page it says:

 {
        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' }
            ]
        }
    },

so if I set the default interval to what I want outside these hours say....once an hour. I don't need to actually HIDE this module in any way....the default will do it's thing until it's 6 am at which time MMM-ModuleSchedualer will push a notification to refresh it every 5 min.....is that correct?

ianperrin commented 5 years ago

@dxfan227 - I’m not aware of MMM-google-route, but a quick look at the ReadMe file suggest you are on the right lines.

You may wish to try a slightly simplified cron expression e.g. */5 6-11 * * * which should trigger MMM-ModuleScheduler to send the notification every 5th minute in the hours from 6 through 11 am. A good tool to test expressions is crontab.guru

dxfan227 commented 5 years ago

thanks for the note! I also posted my question in the mmm-google route git hub page. the dev there say I should use 6-10 ( in regards to my original cron date format) as 6-11 would include 11:05, 11:10,11:15 etc etc.... is that also that case for the example you provided? should it be 6-10 or 6-11 if I want the last refresh at 10:55?

ianperrin commented 5 years ago

Yes that would be the case

dxfan227 commented 5 years ago

Thank you.

ianperrin commented 5 years ago

I note on mrdis/MMM-google-route#16 you ask

Is there any way to check and ensure the schedule is performing as expected?

If you set the debug option to true for MMM-ModuleScheduler, you should receive additional messages to the console/log about the schedules that have been configured.

E.g.


 {
        module: 'MMM-ModuleScheduler',
        config: {
            notification_schedule: [
                // Refresh the route every 5th minute from 6:00 AM to 11:00 AM
                { notification: 'MMM-google-route/refresh', schedule: '*/5 6-10 * * *' }
            ],
            debug: true
        }
 },
dxfan227 commented 5 years ago

thanks! I will give that a try....I did notice in the console, even without adding the debug it does show that it lists the configuration for scheduler and the it's set to next run ( 6 AM) so it seems to be working!

I just have one more issue to tackle. it doesn't relate to your module but maybe you have some ideas on where to look.

the google-route module can listen to notifications from the default calendar module and update it's destination based on that. Which is great and works. the problem is that the calendar module broadcasts the next event info even if it's 20 days into the future.........so while I normally have a map to work ....if I have a meeting somewhere in 20 days the map changes to that destination until them, obviously not what I want.

So I'm trying to see if 1 there is a way for the calendar module to only broad cast an even on the day it occurs......or if there is a way to have mmm-google-route only accept notifications from events that occur that day.......

I don't know if the schedule module can aid in any of this?

ianperrin commented 5 years ago

I suspect that is something which would need changing in the way MMM-google-route handles the calendar notifications - possibly by checking the difference between the current date and the event date is within a period specified in the config options. I think it would need to happen somewhere around L267 in MMM-google-route.js where the event.location is being checked.

One for @mrdis or perhaps you can look into want is needed and submit a pull request to extend the module?

dxfan227 commented 5 years ago

Thank you for looking into it. For me it's gonna be beyond my ability. I don't have any coding experience....Hopefully @mrdis can chime in and see if it's something he would be interested in putting in.

thanks again for all your hard work, great module.