Read the statement by Michael Teeuw here.
modules day and time Depending represented
-
Ok!
i have seen that by the cron Expressions i can only set the startTime and not the EndTime. it’s right?
-
@bjoern you can make another cron task on the endtime
-
So, my current thinking is based around the following config
{ module: 'MMM-ModuleScheduler' }, { module: 'calendar', position: 'top_left', classes: 'scheduler', config: { // Show at 9:00 and hide at 18:00 every day from Monday through Friday module_schedule: {from: '0 9 * * 1-5', to: '0 18 * * 1-5'} } }, { module: 'MMM-soccer', position: 'top_right', classes: 'scheduler', config: { // Show at 9:00 on Saturday and hide at 20:00 on Sunday module_schedule: {from: '0 9 * * SAT', to: '0 20 * * SUN'} } }
Modules would then be shown and hidden based on the addition of a specific class
classes: 'scheduler'
and amodule_schedule
config option containing the cron expressions which control when the module should be shown (from
) and hidden (to
).How does that sound?
p.s. here’s another useful cron resource - http://crontab.guru/
-
YES! That’s gerat!
-
You can easily have another module (module_scheduler?) keep track of time and when require, it can call another module’s .hide() or .show() routine. And you’d want to check on the other module every so often, in case the mirror restarted and re-displayed it.
-
@bjoern - I have created an initial version of MMM-ModuleScheduler and pushed it to github -https://github.com/ianperrin/MMM-ModuleScheduler
If you would like to test it, feel free to install it on your Mirror and report back here.
However, please remember that this is work in progress and has not yet been fully tested, so please do use with care.
-
Seems to work pretty well! I did load it to test it to turn off at 7:50 and it took a while for the mirror to load but I assumed it was the cron preparing itself. The module is indeed off… it didn’t load the Holidays or News feed it just said loading…
So I stopped the mirror and restarted it. It loaded quicker [still slow so people don’t freak out :)]… the Holiday and News Feed did indeed load …
So the only thing NOT on the screen is the thing I attached to the scheduler… so it’s working… Only thing I can see wrong is the speed [decreased] of loading the mirror! BUT it’s not like you start and stop the mirror daily anyway so once it loads it works :)
I like it!! Thank you!!!
-
It’s turning anything off with 'classes: ‘scheduler’, attached no matter what time you set it for ;)
-
@cowboysdude said in modules day and time Depending represented:
Only thing I can see wrong is the speed [decreased] of loading the mirror!
As part of the install process,
npm install
needs to be run to install the dependency onnode-cron
. This can take a little time, but is only required once. Having completed the install, I’m not seeing the performance issues you mention so we might need to look into that a little further. -
@cowboysdude said in modules day and time Depending represented:
It’s turning anything off with 'classes: ‘scheduler’, attached no matter what time you set
The expected functionality is that the module is shown between the dates specified, so once the module has done it’s thing, it hides the modules and they are not shown until the next ‘from’ date.
In more detail, it should follow the following process once it receives the notification (
DOM_OBJECTS_CREATED
) that all modules have been loaded:- It checks each module to see if it contains the ‘scheduler’ class
- If yes, it checks whether the module config includes the ‘module_scheduler’ option
- if yes, it checks whether the option includes the ‘from’ and ‘to’ properties
- if yes, it creates the cron jobs to show (‘from’) and hide (‘to’) the module
- if the next show (‘from’) date for the module is in the future and less than the next hide (‘to’) date, it hides the module
- when the ‘from’ cron job is triggered, it sends a notification to show the module
- when the ‘to’ cron job is triggered, it sends a notification to hide the module
Now, as this is work in progress I haven’t had time to check all permutations of modules and cron expressions. However, it’s logging is rather verbose so please do check out the console log (
pm2 logs mm
) to see what it thinks it is doing!If you find problems, can you post your config (or at the least, which module you are trying to schedule and the values for the
module_scheduler
option?Thanks