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

How can I add more time periods for MMM-compliments?

Scheduled Pinned Locked Moved Solved Requests
20 Posts 4 Posters 6.6k Views 4 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.
  • D Offline
    DæmonEyes
    last edited by DæmonEyes Feb 19, 2019, 5:01 AM Feb 19, 2019, 5:01 AM

    So I know MMM-Compliments has 3 time periods by default (morning, afternoon and evening). I want to know, is it possible to add 1 or 2 more time periods like night and dusk?
    I really enjoy being able to customize the compliments that come up, and would love to have more time slots that I could customize.

    L 1 Reply Last reply Feb 19, 2019, 9:06 AM Reply Quote 0
    • L Offline
      lavolp3 Module Developer @DæmonEyes
      last edited by lavolp3 Feb 19, 2019, 9:06 AM Feb 19, 2019, 9:06 AM

      @dæmoneyes That shouldn’t be too difficult.

      	complimentArray: function() {
      		var hour = moment().hour();
      		var compliments  = null;
      
      		if (hour >= 3 && hour < 12) {
      			compliments = this.config.compliments.morning;
      		} else if (hour >= 12 && hour < 17) {
      			compliments = this.config.compliments.afternoon;
      		} else {
      			compliments = this.config.compliments.evening;
      		}
      
                      .....
      	},
      

      Here is the function calling the hour of the day in MMM-Compliments.js.
      You can easily give this a more precise sorting with more cases.
      However, you would need to change the logic to a switch function, because there can only be one “else if” in an “if” statement.

      Fork the module, try it out!

      How to troubleshoot modules
      MMM-soccer v2, MMM-AVStock

      S 1 Reply Last reply Feb 19, 2019, 10:50 AM Reply Quote 0
      • S Offline
        sdetweil @lavolp3
        last edited by Feb 19, 2019, 10:50 AM

        @lavolp3 said in How can I add more time periods for MMM-compliments?:

        owever, you would need to change the logic to a switch function, because there can only be one “else if” in an “if” statement.

        not true, you can have as many as u want…

        switch sometimes makes things more clear, but not always

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • D Offline
          DæmonEyes
          last edited by DæmonEyes Feb 19, 2019, 6:15 PM Feb 19, 2019, 4:47 PM

          This is actually my first time programming ever, so I don’t actually know what are logic or switch functions.

          This is what I attempted, but it didn’t work, and instead the compliments module just didn’t load up when starting MM:

          ![I added two more time period: predawn and night](https://imgur.com/a/JJrJ01w)
          
          ![Updated the time intervals](https://imgur.com/a/lzAO0gJ)
          
          ![And tried modifying the compliments array as well](https://imgur.com/a/ZiNT8u5)
          
          S 1 Reply Last reply Feb 19, 2019, 4:54 PM Reply Quote 0
          • S Offline
            sdetweil @DæmonEyes
            last edited by Feb 19, 2019, 4:54 PM

            @dæmoneyes your changes didn’t show
            use the three back-tics before and after your code
            on keyboard, left of the number 1 key

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            D 1 Reply Last reply Feb 19, 2019, 6:08 PM Reply Quote 1
            • D Offline
              DæmonEyes @sdetweil
              last edited by DæmonEyes Feb 19, 2019, 6:17 PM Feb 19, 2019, 6:08 PM

              @sdetweil Here are all the changes I tried: https://imgur.com/a/wbYQclq
              alt text

              S 1 Reply Last reply Feb 19, 2019, 6:33 PM Reply Quote 0
              • S Offline
                sdetweil @DæmonEyes
                last edited by Feb 19, 2019, 6:33 PM

                @dæmoneyes start the mirror with

                npm start dev
                

                and in the white developers window, select the console tab,
                scroll up/down to find any errors (red text)…

                I can’t see all your code, but its probably a missing quote, paren or brace

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                D 1 Reply Last reply Feb 19, 2019, 7:04 PM Reply Quote 1
                • D Offline
                  DæmonEyes @sdetweil
                  last edited by Feb 19, 2019, 7:04 PM

                  @sdetweil Did that, found some red related to compliments and also to openweather
                  Here is the full console tab: https://imgur.com/a/Lrn8kVH

                  S 1 Reply Last reply Feb 19, 2019, 7:07 PM Reply Quote 0
                  • S Offline
                    sdetweil @DæmonEyes
                    last edited by Feb 19, 2019, 7:07 PM

                    @dæmoneyes compliments.js:48 syntax error

                    that means on line 48 of the complements.js file the compiler found an error…

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    D 1 Reply Last reply Feb 19, 2019, 7:12 PM Reply Quote 1
                    • D Offline
                      DæmonEyes @sdetweil
                      last edited by DæmonEyes Feb 19, 2019, 7:14 PM Feb 19, 2019, 7:12 PM

                      @sdetweil Once again, I owe you my thanks sdetweil! It works now!

                      What should I do about the red related to the openweathermap?

                      S 1 Reply Last reply Feb 19, 2019, 7:41 PM Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        5/20
                        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