MMM-ModuleScheduler
MMM-ModuleScheduler copied to clipboard
Multiple global schedules can cause modules to start in an unexpected state
I am trying to dim my mirror at nighttime - on weekdays between 10PM and 7AM, on weekends between 10Pm and 8AM. However, the below code does not do the trick - where is my mistake?
{
module: 'MMM-ModuleScheduler',
config: {
global_schedule: [
{from: '0 7 * * 1-5', to: '0 20 * * 1-5', dimLevel: '30'},
{from: '0 8 * * 0,6', to: '0 20 * * 0,6', dimLevel: '30'},
]
}
},
Below is the relevant output of the log (error log is empty). Note that now (Monday at 3 PM) all modules are dimmed though they should not be…
MMM-ModuleScheduler received INITIALISE_SCHEDULER
MMM-ModuleScheduler is setting the config
MMM-ModuleScheduler is removing all scheduled jobs
MMM-ModuleScheduler received CREATE_NOTIFICATION_SCHEDULE
MMM-ModuleScheduler received CREATE_GLOBAL_SCHEDULE
MMM-ModuleScheduler is creating a global schedule for all modules using "0 7 * * 1-5" and "0 20 * * 1-5" with dim level 30
MMM-ModuleScheduler has created the global schedule for all modules
MMM-ModuleScheduler will next show all modules at Tue Dec 20 2016 07:00:00 GMT+0100 (CET)
MMM-ModuleScheduler will next dim all modules at Mon Dec 19 2016 20:00:00 GMT+0100 (CET)
MMM-ModuleScheduler is creating a global schedule for all modules using "0 8 * * 0,6" and "0 20 * * 0,6" with dim level 30
MMM-ModuleScheduler is dimming all modules
MMM-ModuleScheduler has created the global schedule for all modules
MMM-ModuleScheduler will next show all modules at Sat Dec 24 2016 08:00:00 GMT+0100 (CET)
MMM-ModuleScheduler will next dim all modules at Sat Dec 24 2016 20:00:00 GMT+0100 (CET)
Currently, each global schedule is created in the order they are specified in the config file and independently of each other.
In the example configuration, when the MagicMirror is started (or the browser refreshed) the weekday (Mon-Fri) schedule is created, followed by the weekend (Sat, Sun) schedule. As each schedule is created, a check is made to determine whether the modules it relates to should be hidden/dimmed based on the current time and the next trigger times for the from/to cron expressions for that schedule.
Therefore, when the MM starts (or is refreshed) at 3pm on a Monday with this configuration
- The weekday schedule is created, and since the modules should be currently shown (i.e. 3pm on Mon is between 7am and 8pm on Mon-Fri) no change is made to the state of the modules
- The weekend schedule is created, and, according to this schedule, the modules should be currently dimmed (i.e. 3pm on Mon outside is between 8am and 8pm on Sat/Sun) so all modules are dimmed. <- This is not desired.
If the MagicMirror is left running the module should self-correct the problem because
- at 3pm on Mon, the weekday module would start and dim all modules, then
- at 8pm on Mon, the weekday module would try to dim all modules again, then
- at 7am on Tues, the weekday module would show all modules
- after this point the module behaves as expected
However, this is sub-optimal and should be fixed