MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    modules day and time Depending represented

    Scheduled Pinned Locked Moved General Discussion
    29 Posts 7 Posters 20.4k Views 7 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I Offline
      ianperrin
      last edited by

      @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.

      "Live as if you were to die tomorrow. Learn as if you were to live forever." - Mahatma Gandhi

      S 1 Reply Last reply Reply Quote 1
      • cowboysdudeC Offline
        cowboysdude Module Developer
        last edited by cowboysdude

        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!!!

        I 1 Reply Last reply Reply Quote 0
        • cowboysdudeC Offline
          cowboysdude Module Developer
          last edited by

          It’s turning anything off with 'classes: ‘scheduler’, attached no matter what time you set it for ;)

          I 1 Reply Last reply Reply Quote 0
          • I Offline
            ianperrin @cowboysdude
            last edited by

            @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 on node-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.

            "Live as if you were to die tomorrow. Learn as if you were to live forever." - Mahatma Gandhi

            cowboysdudeC 1 Reply Last reply Reply Quote 1
            • I Offline
              ianperrin @cowboysdude
              last edited by

              @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

              "Live as if you were to die tomorrow. Learn as if you were to live forever." - Mahatma Gandhi

              1 Reply Last reply Reply Quote 1
              • I Offline
                ianperrin
                last edited by

                Earlier versions of the module would create duplicate cron jobs if the Mirror recreated the modules (e.g. after a page refresh in the browser). The current version attempts to resolve this.

                Trailblazers who’ve already grabbed a copy of the module please run git pull from the module directory - see https://github.com/ianperrin/MMM-ModuleScheduler#updating for more details

                "Live as if you were to die tomorrow. Learn as if you were to live forever." - Mahatma Gandhi

                1 Reply Last reply Reply Quote 1
                • cowboysdudeC Offline
                  cowboysdude Module Developer @ianperrin
                  last edited by

                  @ianperrin said in modules day and time Depending represented:

                  @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 on node-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.

                  No no it’s only an issue one time … after it loads the first time it’s fine thereafter :)

                  1 Reply Last reply Reply Quote 0
                  • cowboysdudeC Offline
                    cowboysdude Module Developer
                    last edited by

                    Did the git pull and it’s working to perfection… Thank you!!!

                    1 Reply Last reply Reply Quote 0
                    • cowboysdudeC Offline
                      cowboysdude Module Developer
                      last edited by cowboysdude

                      Now here’s a challenge for you LOL

                      Say you’d like a module to appear at 7 am until 8 am then again at 5pm until 11pm could it be worked so it could be set up like this:

                      {
                      module: ‘calendar’,
                      header: ‘US Holidays’,
                      position: ‘top_left’,
                      classes: ‘scheduler’,
                      config: {
                      // DISPLAY THE CALENDAR BETWEEN 09:00 and 18:00 ON WEDNESDAYS
                      schedule1: {from: ‘0 7 * * 3’, to: ‘0 8 * * 3’ },
                      schedule2: {from: ‘0 17 * * 3’, to: ‘0 23 * * 3’ },
                      calendars: [
                      {
                      symbol: 'calendar-check-o ',
                      url: ‘webcal://www.calendarlabs.com/templates/ical/US-Holidays.ics’
                      }
                      ]
                      }
                      },

                      Just a thought but it could be useful :) My other thought was to enter the module twice and run it the way it’s written… going to test that :)

                      I tested that and that works ! :) The logic of the mirror just loads the modules [if in the config correctly] will load it as many times as you want! So I had it come on at 7 and go off at 8:30 then back on at 8:32 and that worked great! Not sure how hard it would be to change it to work but could just add another layer to the module :)

                      1 Reply Last reply Reply Quote 0
                      • I Offline
                        ianperrin
                        last edited by ianperrin

                        @cowboysdude - rather than add two instances of the module, try the following expressions:

                        module_schedule: {from: '0 7,17 * * *', to: '0 8,23 * * *'}
                        

                        This should create a schedule with jobs to show the module at 07:00hrs and 17:00hrs, and jobs to hide the module at 08:00hrs and 23:00hrs

                        I can see there are use cases where multiple schedules might be required, so I’ve created an enhancement request on github to cover that one - https://github.com/ianperrin/MMM-ModuleScheduler/issues/2

                        "Live as if you were to die tomorrow. Learn as if you were to live forever." - Mahatma Gandhi

                        cowboysdudeC 1 Reply Last reply Reply Quote 1
                        • 1
                        • 2
                        • 3
                        • 2 / 3
                        • First post
                          Last post
                        Enjoying MagicMirror? Please consider a donation!
                        MagicMirror created by Michael Teeuw.
                        Forum managed by Sam, technical setup by Karsten.
                        This forum is using NodeBB as its core | Contributors
                        Contact | Privacy Policy