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

Show Module based on date

Scheduled Pinned Locked Moved Unsolved Requests
10 Posts 7 Posters 1.1k Views 6 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.
  • S Offline
    soldado48
    last edited by Jun 21, 2022, 4:58 PM

    Id like to display a module based on a date and time.
    For example a commute Module to only show if its in the morning during a weekeday.

    Anyway to do this?

    C 1 Reply Last reply Jun 21, 2022, 9:25 PM Reply Quote 0
    • C Offline
      cowboysdude Module Developer @soldado48
      last edited by Jun 21, 2022, 9:25 PM

      @soldado48 Just about anything is possible. You can add config entries to show or hide a module based on day/date … time would be a bit more difficult but doable.

      S 1 Reply Last reply Jun 21, 2022, 9:31 PM Reply Quote 0
      • S Offline
        sdetweil @cowboysdude
        last edited by Jun 21, 2022, 9:31 PM

        @cowboysdude where that day/date?

        in the base?

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • M Offline
          MMRIZE
          last edited by Jun 23, 2022, 12:39 PM

          A combination of cron and some commandable - Notification emittable modules would work.

          S 1 Reply Last reply Jun 23, 2022, 2:11 PM Reply Quote 0
          • S Offline
            sdetweil @MMRIZE
            last edited by Jun 23, 2022, 2:11 PM

            @MMRIZE yes, but not in the base.

            have to add other stuff

            cron and remotecontrol
            or something like that

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • M Offline
              Mr.Fliffer
              last edited by Jun 26, 2022, 4:38 PM

              You can add the MMMRemoteControl Module to your config file. In a seperat Script you can send commands to Show or hide modules. You can run the Script in python for example.

              1 Reply Last reply Reply Quote 0
              • S Offline
                Snille Module Developer
                last edited by Snille Jun 28, 2022, 11:11 AM Jun 28, 2022, 10:56 AM

                I’m doing this on my setup, I’m using “MMM-ProfileSwitcher”. There you can do just about anything regarding showing a / a group of modules on different times/ dates…
                I group mu modules with the “classes” option…
                So the clock looks like this:

                		{
                			disabled: false,
                			module: "clock",
                			hiddenOnStartup: true,
                			position: "top_left",
                			header: "Datum och tid",
                			classes: "default Erik Camilla Louise Media Jobba Väder Födelsedag small",
                			config: {
                				showDate: true,
                				dateFormat: "YYYY-MM-DD",
                				showWeek: true
                			}
                		},
                

                It’s shown for almost all profiles… :)

                Here are some parts of my conf…

                My global settings for the module...
                		{
                			disabled: false,
                			module: "MMM-ProfileSwitcher",
                			hiddenOnStartup: true,
                			header: "Profile",
                			classes: "none",
                			config: {
                				title: false,
                				useLockStrings: false,
                				defaultTime: 600000,
                				enterMessages: {
                					"Erik Camilla Louise Kakan Cappuccino": "Hej %profile%!",
                					"Erik": ["Hoppas dagen varit bra Erik!", "Ser man på, välkommen Erik!", "Kul att se dig Erik!"],
                					"Camilla": ["Toppendag hoppas jag, Camilla!", "Oh, trevligt att se dig Camilla!", "Kul att se dig Camilla!"],
                					"Louise": ["Kul i skolan idag Louise?", "Lekt något skoj idag Louise?", "Kul att se dig Louise!"],
                					"Media": ["Hej, här är allt nytt!", "Här finns mycket nytt!", "Ny media!", "Hoppas det finns något att se."],
                					"Jobba": ["Dags att jobba nu!", "Jobba på nu!", "Var på tiden!", "Dagen är inte slut än!"],
                					"Klocka": ["Var på tiden!"],
                					"Väder": ["Dags för väder!", "Här är allt om vädret!", "Hoppas det blir fint väder.", "Glöm inte att kolla vädret!"],
                					"Skattjakt": ["Skattjakten är igång!", "Nu blir det skattjakt!", "Äntligen skattjakt!"],
                					"Grattis": ["Bra jobbat!", "Grattis!"],
                				},
                				leaveMessages: {
                					"everyone": "Hejdå %profile%...",
                					"Erik": ["Hejdå, jag kommer sakna dig...", true],
                					"Camilla": ["Hejdå Camilla.", true],
                					"Louise": ["Hejdå Louise.", true],
                					"Media": ["Hoppas du hittade något.", true],
                					"Jobba": ["Jobbat klart redan!?", true],
                					"Klocka": ["Slut på tiden.", true],
                					"Väder": ["Ha så trevligt.", true],
                					"Skattjakt": ["Hoppas det varit kul!"],
                					"Grattis": ["Ses om ett år..."],
                				},
                				timers: {
                					"Erik": {},
                					"Camilla": {},
                					"Louise": {},
                					"Kakan": {},
                					"Cappuccino": {},
                					"Klocka": {},
                				},
                				ignoreModules: ["alert", "updatenotification"]
                			}
                		},
                
                Then I have a specific module for halloween.... :)
                		{
                			disabled: false,
                			module: 'MMM-Videoplayer',
                			hiddenOnStartup: true,
                			position: "fullscreen_below",
                			classes: "scheduler turn90",
                			config: {
                				random: true,
                				loop: true,
                				hideonstart: true,
                				notification: "VIDEOPLAYER1",
                				videolist: ["a",
                					    "list",
                					    "of", 
                					    "videos..."],
                				module_schedule: [
                					{from: '0 6 31 9 *', to: '3 6 31 9 *'},
                					{from: '6 6 31 9 *', to: '9 6 31 9 *'},
                					{from: '12 6 31 9 *', to: '15 6 31 9 *'},
                					{from: '18 6 31 9 *', to: '21 6 31 9 *'},
                					{from: '24 6 31 9 *', to: '27 6 31 9 *'},
                					{from: '30 6 31 9 *', to: '33 6 31 9 *'},
                					{from: '36 6 31 9 *', to: '39 6 31 9 *'},
                					{from: '42 6 31 9 *', to: '45 6 31 9 *'},
                					{from: '48 6 31 9 *', to: '51 6 31 9 *'},
                					{from: '54 6 31 9 *', to: '57 6 31 9 *'},
                					{from: '0 7 31 9 *', to: '3 7 31 9 *'},
                					{from: '6 7 31 9 *', to: '9 7 31 9 *'},
                					{from: '12 7 31 9 *', to: '15 7 31 9 *'},
                					{from: '18 7 31 9 *', to: '21 7 31 9 *'},
                					{from: '24 7 31 9 *', to: '27 7 31 9 *'},
                					{from: '30 7 31 9 *', to: '33 7 31 9 *'},
                					{from: '36 7 31 9 *', to: '39 7 31 9 *'},
                					{from: '42 7 31 9 *', to: '45 7 31 9 *'},
                					{from: '48 7 31 9 *', to: '51 7 31 9 *'},
                					{from: '54 7 31 9 *', to: '57 7 31 9 *'},
                					{from: '0 8 31 9 *', to: '3 8 31 9 *'},
                					{from: '6 8 31 9 *', to: '9 8 31 9 *'},
                					{from: '12 8 31 9 *', to: '15 8 31 9 *'},
                					{from: '18 8 31 9 *', to: '21 8 31 9 *'},
                					{from: '24 8 31 9 *', to: '27 8 31 9 *'},
                					{from: '30 8 31 9 *', to: '33 8 31 9 *'},
                					{from: '36 8 31 9 *', to: '39 8 31 9 *'},
                					{from: '42 8 31 9 *', to: '45 8 31 9 *'},
                					{from: '48 8 31 9 *', to: '51 8 31 9 *'},
                					{from: '54 8 31 9 *', to: '57 8 31 9 *'},
                					{from: '0 9 31 9 *', to: '3 9 31 9 *'},
                					{from: '6 9 31 9 *', to: '9 9 31 9 *'},
                					{from: '12 9 31 9 *', to: '15 9 31 9 *'},
                					{from: '18 9 31 9 *', to: '21 9 31 9 *'},
                					{from: '24 9 31 9 *', to: '27 9 31 9 *'},
                					{from: '30 9 31 9 *', to: '33 9 31 9 *'},
                					{from: '36 9 31 9 *', to: '39 9 31 9 *'},
                					{from: '42 9 31 9 *', to: '45 9 31 9 *'},
                					{from: '48 9 31 9 *', to: '51 9 31 9 *'},
                					{from: '54 9 31 9 *', to: '57 9 31 9 *'},
                					{from: '0 10 31 9 *', to: '3 10 31 9 *'},
                					{from: '6 10 31 9 *', to: '9 10 31 9 *'},
                					{from: '12 10 31 9 *', to: '15 10 31 9 *'},
                					{from: '18 10 31 9 *', to: '21 10 31 9 *'},
                					{from: '24 10 31 9 *', to: '27 10 31 9 *'},
                					{from: '30 10 31 9 *', to: '33 10 31 9 *'},
                					{from: '36 10 31 9 *', to: '39 10 31 9 *'},
                					{from: '42 10 31 9 *', to: '45 10 31 9 *'},
                					{from: '48 10 31 9 *', to: '51 10 31 9 *'},
                					{from: '54 10 31 9 *', to: '57 10 31 9 *'},
                					{from: '0 11 31 9 *', to: '3 11 31 9 *'},
                					{from: '6 11 31 9 *', to: '9 11 31 9 *'},
                					{from: '12 11 31 9 *', to: '15 11 31 9 *'},
                					{from: '18 11 31 9 *', to: '21 11 31 9 *'},
                					{from: '24 11 31 9 *', to: '27 11 31 9 *'},
                					{from: '30 11 31 9 *', to: '33 11 31 9 *'},
                					{from: '36 11 31 9 *', to: '39 11 31 9 *'},
                					{from: '42 11 31 9 *', to: '45 11 31 9 *'},
                					{from: '48 11 31 9 *', to: '51 11 31 9 *'},
                					{from: '54 11 31 9 *', to: '57 11 31 9 *'},
                					{from: '0 12 31 9 *', to: '3 12 31 9 *'},
                					{from: '6 12 31 9 *', to: '9 12 31 9 *'},
                					{from: '12 12 31 9 *', to: '15 12 31 9 *'},
                					{from: '18 12 31 9 *', to: '21 12 31 9 *'},
                					{from: '24 12 31 9 *', to: '27 12 31 9 *'},
                					{from: '30 12 31 9 *', to: '33 12 31 9 *'},
                					{from: '36 12 31 9 *', to: '39 12 31 9 *'},
                					{from: '42 12 31 9 *', to: '45 12 31 9 *'},
                					{from: '48 12 31 9 *', to: '51 12 31 9 *'},
                					{from: '54 12 31 9 *', to: '57 12 31 9 *'},
                					{from: '0 13 31 9 *', to: '3 13 31 9 *'},
                					{from: '6 13 31 9 *', to: '9 13 31 9 *'},
                					{from: '12 13 31 9 *', to: '15 13 31 9 *'},
                					{from: '18 13 31 9 *', to: '21 13 31 9 *'},
                					{from: '24 13 31 9 *', to: '27 13 31 9 *'},
                					{from: '30 13 31 9 *', to: '33 13 31 9 *'},
                					{from: '36 13 31 9 *', to: '39 13 31 9 *'},
                					{from: '42 13 31 9 *', to: '45 13 31 9 *'},
                					{from: '48 13 31 9 *', to: '51 13 31 9 *'},
                					{from: '54 13 31 9 *', to: '57 13 31 9 *'},
                					{from: '0 14 31 9 *', to: '3 14 31 9 *'},
                					{from: '6 14 31 9 *', to: '9 14 31 9 *'},
                					{from: '12 14 31 9 *', to: '15 14 31 9 *'},
                					{from: '18 14 31 9 *', to: '21 14 31 9 *'},
                					{from: '24 14 31 9 *', to: '27 14 31 9 *'},
                					{from: '30 14 31 9 *', to: '33 14 31 9 *'},
                					{from: '36 14 31 9 *', to: '39 14 31 9 *'},
                					{from: '42 14 31 9 *', to: '45 14 31 9 *'},
                					{from: '48 14 31 9 *', to: '51 14 31 9 *'},
                					{from: '54 14 31 9 *', to: '57 14 31 9 *'},
                					{from: '0 15 31 9 *', to: '3 15 31 9 *'},
                					{from: '6 15 31 9 *', to: '9 15 31 9 *'},
                					{from: '12 15 31 9 *', to: '15 15 31 9 *'},
                					{from: '18 15 31 9 *', to: '21 15 31 9 *'},
                					{from: '24 15 31 9 *', to: '27 15 31 9 *'},
                					{from: '30 15 31 9 *', to: '33 15 31 9 *'},
                					{from: '36 15 31 9 *', to: '39 15 31 9 *'},
                					{from: '42 15 31 9 *', to: '45 15 31 9 *'},
                					{from: '48 15 31 9 *', to: '51 15 31 9 *'},
                					{from: '54 15 31 9 *', to: '57 15 31 9 *'},
                					{from: '0 16 31 9 *', to: '3 16 31 9 *'},
                					{from: '6 16 31 9 *', to: '9 16 31 9 *'},
                					{from: '12 16 31 9 *', to: '15 16 31 9 *'},
                					{from: '18 16 31 9 *', to: '21 16 31 9 *'},
                					{from: '24 16 31 9 *', to: '27 16 31 9 *'},
                					{from: '30 16 31 9 *', to: '33 16 31 9 *'},
                					{from: '36 16 31 9 *', to: '39 16 31 9 *'},
                					{from: '42 16 31 9 *', to: '45 16 31 9 *'},
                					{from: '48 16 31 9 *', to: '51 16 31 9 *'},
                					{from: '54 16 31 9 *', to: '57 16 31 9 *'},
                					{from: '0 17 31 9 *', to: '3 17 31 9 *'},
                					{from: '6 17 31 9 *', to: '9 17 31 9 *'},
                					{from: '12 17 31 9 *', to: '15 17 31 9 *'},
                					{from: '18 17 31 9 *', to: '21 17 31 9 *'},
                					{from: '24 17 31 9 *', to: '27 17 31 9 *'},
                					{from: '30 17 31 9 *', to: '33 17 31 9 *'},
                					{from: '36 17 31 9 *', to: '39 17 31 9 *'},
                					{from: '42 17 31 9 *', to: '45 17 31 9 *'},
                					{from: '48 17 31 9 *', to: '51 17 31 9 *'},
                					{from: '54 17 31 9 *', to: '57 17 31 9 *'},
                					{from: '0 18 31 9 *', to: '3 18 31 9 *'},
                					{from: '6 18 31 9 *', to: '9 18 31 9 *'},
                					{from: '12 18 31 9 *', to: '15 18 31 9 *'},
                					{from: '18 18 31 9 *', to: '21 18 31 9 *'},
                					{from: '24 18 31 9 *', to: '27 18 31 9 *'},
                					{from: '30 18 31 9 *', to: '33 18 31 9 *'},
                					{from: '36 18 31 9 *', to: '39 18 31 9 *'},
                					{from: '42 18 31 9 *', to: '45 18 31 9 *'},
                					{from: '48 18 31 9 *', to: '51 18 31 9 *'},
                					{from: '54 18 31 9 *', to: '57 18 31 9 *'},
                					{from: '0 19 31 9 *', to: '3 19 31 9 *'},
                					{from: '6 19 31 9 *', to: '9 19 31 9 *'},
                					{from: '12 19 31 9 *', to: '15 19 31 9 *'},
                					{from: '18 19 31 9 *', to: '21 19 31 9 *'},
                					{from: '24 19 31 9 *', to: '27 19 31 9 *'},
                					{from: '30 19 31 9 *', to: '33 19 31 9 *'},
                					{from: '36 19 31 9 *', to: '39 19 31 9 *'},
                					{from: '42 19 31 9 *', to: '45 19 31 9 *'},
                					{from: '48 19 31 9 *', to: '51 19 31 9 *'},
                					{from: '54 19 31 9 *', to: '57 19 31 9 *'},
                					{from: '0 20 31 9 *', to: '3 20 31 9 *'},
                					{from: '6 20 31 9 *', to: '9 20 31 9 *'},
                					{from: '12 20 31 9 *', to: '15 20 31 9 *'},
                					{from: '18 20 31 9 *', to: '21 20 31 9 *'},
                					{from: '24 20 31 9 *', to: '27 20 31 9 *'},
                					{from: '30 20 31 9 *', to: '33 20 31 9 *'},
                					{from: '36 20 31 9 *', to: '39 20 31 9 *'},
                					{from: '42 20 31 9 *', to: '45 20 31 9 *'},
                					{from: '48 20 31 9 *', to: '51 20 31 9 *'},
                					{from: '54 20 31 9 *', to: '57 20 31 9 *'},
                					{from: '0 21 31 9 *', to: '3 21 31 9 *'},
                					{from: '6 21 31 9 *', to: '9 21 31 9 *'},
                					{from: '12 21 31 9 *', to: '15 21 31 9 *'},
                					{from: '18 21 31 9 *', to: '21 21 31 9 *'},
                					{from: '24 21 31 9 *', to: '27 21 31 9 *'},
                					{from: '30 21 31 9 *', to: '33 21 31 9 *'},
                					{from: '36 21 31 9 *', to: '39 21 31 9 *'},
                					{from: '42 21 31 9 *', to: '45 21 31 9 *'},
                					{from: '48 21 31 9 *', to: '51 21 31 9 *'},
                					{from: '54 21 31 9 *', to: '57 21 31 9 *'},
                					{from: '0 22 31 9 *', to: '3 22 31 9 *'},
                					{from: '6 22 31 9 *', to: '9 22 31 9 *'},
                					{from: '12 22 31 9 *', to: '15 22 31 9 *'},
                					{from: '18 22 31 9 *', to: '21 22 31 9 *'},
                					{from: '24 22 31 9 *', to: '27 22 31 9 *'},
                					{from: '30 22 31 9 *', to: '33 22 31 9 *'},
                					{from: '36 22 31 9 *', to: '39 22 31 9 *'},
                					{from: '42 22 31 9 *', to: '45 22 31 9 *'},
                					{from: '48 22 31 9 *', to: '51 22 31 9 *'},
                					{from: '54 22 31 9 *', to: '57 22 31 9 *'},
                				]
                			}
                		},
                Basically it plays a random video in the background of the mirror every 6 minutes from 06:00 to 23. :)
                

                I hope this gives some ideas how to do stuff… :)

                If you cant find it, make it and share it!
                Modules: MMM-homeassistant-sensors, MMM-Modulebar, MMM-Profilepicture, MMM-Videoplayer

                1 Reply Last reply Reply Quote 1
                • S Offline
                  shin10 Module Developer
                  last edited by Aug 1, 2022, 5:10 PM

                  Hi there,

                  I’ve recently written a module to inject custom code/styles for simple tasks and modifications like this. https://github.com/shin10/MMM-FF-code-injector

                  The following config for example will show the clock module only Mon - Fri, 06:00 - 10:00. I just tested it with MMM-Pages and it works quite nice.

                  {
                    module: "MMM-FF-code-injector",
                    disabled: false,
                    config: {
                      position: "top",
                      scripts: {
                        intervals:[  {
                          interval: 60 * 1000, // test all 60 seconds
                          description: "Show module only Mon - Fri, 06:00 - 10:00",
                          func: function() {
                            MM.getModules().enumerate((module) => {
                              if (module.name === "clock") { // name of the module to show/hide
                                let now = new Date();
                                let day = now.getDay();
                                if (day >= 1 && day <= 5) { // mon -fri
                                  let hour = now.getHours();
                                  if(hour >= 6 && hour <= 10) { // 06:00 - 10:00
                                    module.show(1000, { lockString: "code-injector"});
                                    return
                                  }
                                }
                                module.hide(1000, { lockString: "code-injector"});
                              }
                            });
                          }
                        }]
                      },
                    },
                  },
                  
                  S 1 Reply Last reply Aug 1, 2022, 7:10 PM Reply Quote 0
                  • S Offline
                    sdetweil @shin10
                    last edited by Aug 1, 2022, 7:10 PM

                    @shin10 you could also use node-cron library and then you wouldn’t have to have all this date/time checking

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    S 1 Reply Last reply Aug 1, 2022, 8:10 PM Reply Quote 0
                    • S Offline
                      shin10 Module Developer @sdetweil
                      last edited by shin10 Aug 1, 2022, 8:12 PM Aug 1, 2022, 8:10 PM

                      @sdetweil For sure. I just hadn’t thought about that usecase till now. It’s just a little helper to things done without the need for writing a dedicated module and do some hacking. So I’d prefer to keep it free of dependencies.

                      That said, anyone in the need for a cron might be better off with MMM-ModuleScheduler. Hadn’t known about this (I’m pretty new to MM), but it seems to be the one @Snille is actually using, despite he mentioned the profile switcher instead? And it seems to do exactly what the the op asked for: https://github.com/ianperrin/MMM-ModuleScheduler#individual-module-schedules

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • 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