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 22.9k 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

      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
              • cowboysdudeC Offline
                cowboysdude Module Developer @ianperrin
                last edited by cowboysdude

                @ianperrin Thank you! I’ll give that a go when I get home from work. This module is just about the handiest things I have seen!!!

                I guess had I investigated cron I could have found that out myself… sorry.

                With this I no longer wish the pi to ‘go to sleep’… I just show certain things at certain times and always leave the time and date on… it’s just amazing!!! You don’t realize how useful and important something sometimes until you have it!

                Thanks again!

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

                  @ianperrin I installed this modules and it found working fine.

                  I S 2 Replies Last reply Reply Quote 0
                  • I Offline
                    ianperrin @shashank
                    last edited by

                    @shashank - great to hear - and thanks for the feedback.

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

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

                      @cowboysdude said in modules day and time Depending represented:

                      I guess had I investigated cron I could have found that out myself… sorry.

                      Glad to help and no need to apologise at all

                      "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
                      • MitchfarinoM Offline
                        Mitchfarino Module Developer
                        last edited by

                        Not implemented this yet @ianperrin , but this is an incredible contribution. We can make much more use of the modules now, rather than being limited to a certain number

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

                          @Mitchfarino said in modules day and time Depending represented:

                          Not implemented this yet @ianperrin , but this is an incredible contribution. We can make much more use of the modules now, rather than being limited to a certain number

                          This should be right in the install!! :)

                          1 Reply Last reply Reply Quote 0
                          • B Offline
                            bjoern
                            last edited by

                            WORKS FINE! Thanks!

                            1 Reply Last reply Reply Quote 0
                            • S Offline
                              shashank @shashank
                              last edited by

                              @shashank i configured this scheduler today with Calendar and Wunderground, after the end time the module will not disappear, i need to stop and start the MM.

                              {
                              module: ‘calendar’,
                              header: ‘US Holidays’,
                              position: ‘top_left’,
                              classes: ‘scheduler’,
                              config: {
                              // DISPLAY THE CALENDAR BETWEEN 09:00 and 18:00 ON WEDNESDAYS
                              module_schedule: {from: ‘0 9 * * FRI’, to: ‘20 21 * * SAT’ },
                              calendars: [
                              {
                              symbol: 'calendar-check-o ',
                              url: ‘webcal://www.calendarlabs.com/templates/ical/US-Holidays.ics’
                              }
                              ]
                              }
                              },

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

                                @shashank said in modules day and time Depending represented:
                                Looking at your config, I can see a couple of potential issues

                                Firstly, make sure you use straight apostrophes (') not curly ones (‘ ’).

                                Secondly, the expressions in the module_schedule config option (module_schedule: {from: '0 9 * * FRI', to: '20 21 * * SAT' },) should schedule the calendar so it is displayed at 09:00 on Friday and be hidden at 21:20 on Saturday.

                                Is this what you intended? If so, check the logs (pm2 logs mm), you should see something like this.

                                MMM-ModuleScheduler received CREATE_MODULE_SCHEDULE
                                MMM-ModuleScheduler is scheduling calendar using '0 9 * * FRI' and '20 21 * * SAT'
                                MMM-ModuleScheduler has scheduled calendar
                                MMM-ModuleScheduler will next show calendar at Fri Sep 23 2016 09:00:00 GMT+0000 (UTC)
                                MMM-ModuleScheduler will next hide calendar at Sat Sep 17 2016 21:20:00 GMT+0000 (UTC)
                                

                                Note the last two lines will vary depending on when start the mirror. In the example above started the mirror at 17:00 on Saturday, so the next ‘show’ (from) date is next friday (23rd) and the next hide (to) date is tonight.

                                Hope this helps

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

                                MitchfarinoM 1 Reply Last reply Reply Quote 0
                                • MitchfarinoM Offline
                                  Mitchfarino Module Developer @ianperrin
                                  last edited by

                                  @ianperrin

                                  Sorry for the odd question, will this work on a windows PC?

                                  I’m testing the mirror on the PC before I deploy to my Pi, and this module doesn’t seem to be working

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

                                    @Mitchfarino I’ve not tested the module on windows myself, so I can’t say for sure.

                                    The module requires the cron package so make sure this has been installed by running npm install from the module folder.

                                    You could then check whether cron works on windows by entering the following from the command prompt

                                    cd MagicMirror/modules/MMM-ModuleScheduler
                                    node
                                    

                                    Once the node prompt appears, enter the following

                                    var CronJob = require('cron').CronJob;
                                    var testJob = new CronJob({cronTime: '* * * * * *', onTick: function() { console.log('Firing every second'); }, onComplete: function() { console.log('Stopping'); }, start: true});
                                    console.log('Scheduled for ' + testJob.nextDate().toDate());
                                    

                                    You should see a telling you when the module is next scheduled for and another message every second the expression is fired (pressCTRL-C twice to stop!)

                                    If we’ve got this far cron is working successfully. What do the logs ( pm2 logs mm ) say? Could you post your config options?

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

                                    1 Reply Last reply Reply Quote 0

                                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                    With your input, this post could be even better 💗

                                    Register Login
                                    • 1
                                    • 2
                                    • 2 / 2
                                    • 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