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

Can a module have two or more schedules? #20

Closed freelancemke closed 5 years ago

freelancemke commented 5 years ago

I have a module that I want to show in the morning then hide and then again in the evening and then hide. As an example I have:

{
    module: 'clock',
    position: 'top_right',      
    classes: 'scheduler',   
            config: {       
                module_schedule: {from: '0 7 * * 1-5', to: '0 8 * * 1-5' },     
                module_schedule: {from: '0 19 * * 1-5', to: '0 20 * * 1-5' },   

            }
        },

If i duplicate the module and make one for the AM and the other for PM then it works, but am I wrong is it just not possible to have it schedule both in the morning and evening of the same day?

ianperrin commented 5 years ago

You should be able to achieve this with one schedule. Try this

module_schedule: {from: '0 7,19 * * 1-5', to: '0 8,20 * * 1-5'}
freelancemke commented 5 years ago

I will give that a try when I can... should be able to let you know tomorrow when I'm back at my device. Thanks for the prompt response.

freelancemke commented 5 years ago

Thank you I think that worked for events that happen on the same day. But expanding on that, if I add another line for the the weekend, it seems to not display the module during either of the scheduled times my new script is


module_schedule: {from: '0 7,19 * * 1-5', to: '0 8,20 * * 1-5'},
module_schedule: {from: '0 15 * * SAT,SUN', to: '0 16 * * SAT,SUN'}

If i comment one line or the other out in my tests then they run fine, but again not when there are two. Suggestions?

ianperrin commented 5 years ago

Ah so this is a slightly different question. Let’s see if we can answer it.

As you’ve seen, it’s not possible to set a config option multiple times for the same module.

So, if a single module schedule can’t meet your needs, then it should be possible to pass multiple module schedules in an array.

Try this

module_schedule: [{from: '0 7,19 * * 1-5', to: '0 8,20 * * 1-5'},
                  {from: '0 15 * * 6,0', to: '0 16 * * 6,0'}]
freelancemke commented 5 years ago

Great! that works from what I can tell so far. Didn't think of putting them in an array. New to programming and just trying to get my bearings with things. Really appreciate your prompt response!