• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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 18.6k 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 Sep 13, 2016, 1:09 PM

    @bjoern - a common way of scheduling activity is use cron expressions which give an enormous amount of flexibility for defining when things should happen.

    I would think this is a better way to tackle the solution rather than try to create custom scheduling logic.

    I’ve built the basis of the module which hides and shows other modules based on the config options, but will need a little time to add and test the scheduling. Give me a day or so.

    Ian

    "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
    • B Offline
      bjoern
      last edited by Sep 14, 2016, 6:03 AM

      Ok!

      i have seen that by the cron Expressions i can only set the startTime and not the EndTime. it’s right?

      S 1 Reply Last reply Sep 14, 2016, 7:43 AM Reply Quote 0
      • S Offline
        strawberry 3.141 Project Sponsor Module Developer @bjoern
        last edited by Sep 14, 2016, 7:43 AM

        @bjoern you can make another cron task on the endtime

        Please create a github issue if you need help, so I can keep track

        1 Reply Last reply Reply Quote 1
        • I Offline
          ianperrin
          last edited by ianperrin Sep 14, 2016, 8:40 AM Sep 14, 2016, 8:31 AM

          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 a module_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/

          "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
          • B Offline
            bjoern
            last edited by Sep 14, 2016, 11:04 AM

            YES! That’s gerat!

            1 Reply Last reply Reply Quote 0
            • K Offline
              KirAsh4 Moderator
              last edited by Sep 14, 2016, 11:21 AM

              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.

              A Life? Cool! Where can I download one of those from?

              1 Reply Last reply Reply Quote 1
              • I Offline
                ianperrin
                last edited by Sep 14, 2016, 9:34 PM

                @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 Sep 16, 2016, 3:34 PM Reply Quote 1
                • C Offline
                  cowboysdude Module Developer
                  last edited by cowboysdude Sep 15, 2016, 12:07 AM Sep 15, 2016, 12:06 AM

                  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 Sep 15, 2016, 6:02 AM Reply Quote 0
                  • C Offline
                    cowboysdude Module Developer
                    last edited by Sep 15, 2016, 2:07 AM

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

                    I 1 Reply Last reply Sep 15, 2016, 6:19 AM Reply Quote 0
                    • I Offline
                      ianperrin @cowboysdude
                      last edited by Sep 15, 2016, 6:02 AM

                      @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

                      C 1 Reply Last reply Sep 15, 2016, 9:30 PM Reply Quote 1
                      • 1
                      • 2
                      • 3
                      • 1 / 3
                      1 / 3
                      • First post
                        7/29
                        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