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.

    2.32.0 Calendar module limitDays and excludedEvents stopped working

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    41 Posts 5 Posters 2.6k Views 5 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
      sdetweil @sdetweil
      last edited by

      @AndyHazz ok, got it too… this one looks like a javascript difference in scopes…
      I added the Log.debug lines, they are not important
      modules/default/calendar/calendarfetcherutils.js , starting line 18 (4 changes total)
      see // change this line

      	shouldEventBeExcluded (config, title) {
      		let result = {  // change this line
      			excluded: false,
      			until: null
      		};
      		for (let f in config.excludedEvents) {
      			let filter = config.excludedEvents[f],  // this line uses the same variable name, filter,   now we have two,
      				testTitle = title.toLowerCase(),
      				until = null,
      				useRegex = false,
      				regexFlags = "g";
      
      			if (filter instanceof Object) {  
      				if (typeof filter.until !== "undefined") {
      					until = filter.until;
      				}
      
      				if (typeof filter.regex !== "undefined") {
      					useRegex = filter.regex;
      				}
      
      				// If additional advanced filtering is added in, this section
      				// must remain last as we overwrite the filter object with the
      				// filterBy string
      				if (filter.caseSensitive) {
      					filter = filter.filterBy;
      					testTitle = title;
      				} else if (useRegex) {
      					filter = filter.filterBy;
      					testTitle = title;
      					regexFlags += "i";
      				} else {
      					filter = filter.filterBy.toLowerCase();
      				}
      			} else {
      				filter = filter.toLowerCase();
      			}
      			Log.debug("should be excluded ", testTitle, filter, useRegex, regexFlags)
      			if (CalendarFetcherUtils.titleFilterApplies(testTitle, filter, useRegex, regexFlags)) {				
      				if (until) {
      					result.until = until;  // change this line
      				} else {
      					Log.debug("event should be excluded = true,", testTitle )
      					result.excluded = true;  // change this line
      				}
      				Log.debug("filter applies result =", result)
      				break;
      			}
      		}
      		Log.debug("filter applies returning =", result)
      		return result;  // change this line 
      	},
      

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      A 1 Reply Last reply Reply Quote 0
      • A Offline
        AndyHazz Project Sponsor @sdetweil
        last edited by

        @sdetweil perhaps I’m missing something, but that’s not working for me - it’s made no difference, excluded events are still appearing … I’ve double checked and can’t spot anything amiss, I’ve made the 4 changes from ‘filter’ to ‘result’?

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

          @AndyHazz hm…
          my config parm for excluded Events

          I added one event for saturday… without excluded it shows, with excluded it doesn’t

                     excludedEvents: [
                          'Birthday'
                      ],
          

          I checked the changed lines and only see those 4
          - is old line
          + is new line

                   * until: the date until the event should be excluded.
                   */
                  shouldEventBeExcluded (config, title) {
          -               let filter = {
          +               let result = {
                                  excluded: false,
                                  until: null
                          };
          @@ -52,17 +52,20 @@ const CalendarFetcherUtils = {
                                  } else {
                                          filter = filter.toLowerCase();
                                  }
                                 if (CalendarFetcherUtils.titleFilterApplies(testTitle, filter, useRegex, regexFlags)) {                         
                                          if (until) {
          -                                       filter.until = until;
          +                                       result.until = until;
                                          } else {
          -                                       filter.excluded = true;
          +                                       result.excluded = true;
                                          }
                                          break;
                                  }
                          }
          -               return filter;
          +               return result;
                  },
          

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          A 1 Reply Last reply Reply Quote 0
          • A Offline
            AndyHazz Project Sponsor @sdetweil
            last edited by

            @sdetweil yep that’s what I’ve got, copying below in case I’m missing something …

            I’ve also added your debug messages back in and changed Log.debug to console.log (as I still can’t get any debug logs from docker but I do get console.log messages from other modules) but nothing comes out in the console log - seems odd that all these changes have had zero effect, am I missing something that might be needed to get these changes to kick in?

                    shouldEventBeExcluded (config, title) {
                            let result = {  // CHANGED
                                    excluded: false,
                                    until: null
                            };
                            for (let f in config.excludedEvents) {
                                    let filter = config.excludedEvents[f],
                                            testTitle = title.toLowerCase(),
                                            until = null,
                                            useRegex = false,
                                            regexFlags = "g";
                                    if (filter instanceof Object) {
                                            if (typeof filter.until !== "undefined") {
                                                    until = filter.until;
                                            }
            
                                            if (typeof filter.regex !== "undefined") {
                                                    useRegex = filter.regex;
                                            }
            
                                            // If additional advanced filtering is added in, this section
                                            // must remain last as we overwrite the filter object with the
                                            // filterBy string
                                            if (filter.caseSensitive) {
                                                    filter = filter.filterBy;
                                                    testTitle = title;
                                            } else if (useRegex) {
                                                    filter = filter.filterBy;
                                                    testTitle = title;
                                                    regexFlags += "i";
                                            } else {
                                                    filter = filter.filterBy.toLowerCase();
                                            }
                                    } else {
                                            filter = filter.toLowerCase();
                                    }
                                    console.log("should be excluded ", testTitle, filter, useRegex, regexFlags)
                                    if (CalendarFetcherUtils.titleFilterApplies(testTitle, filter, useRegex, regexFlags)) {
                                            if (until) {
                                                    result.until = until;  // CHANGED
                                            } else {
                                                    console.log("event should be excluded = true,", testTitle )
                                                    result.excluded = true;  // CHANGED
                                            }
                                            console.log("filter applies result =", result)
                                            break;
                                    }
                            }
                            console.log("filter applies returning =", result)
                            return result;  // CHANGED
                    },
            

            p.s. just spotted comment on line 12 😅

            TODO This seems like an overly complicated way to exclude events based on the title.
            
            S 1 Reply Last reply Reply Quote 0
            • S Offline
              sdetweil @AndyHazz
              last edited by sdetweil

              @AndyHazz note that the excluded events is an ARRAY (so for loop to look thru them )
              test ALL til find one that is true (CalendarFetcherUtils.titleFilterApplies returns true) , or not

              AND the item in the array can be an object with more specific controls, or a string

              MM doc entries on separate lines

              [
              'Birthday',     // text 
              'Hide This Event',    // text 
              {filterBy: 'Payment', until: '6 days', caseSensitive: true},  // complex, but text
              {filterBy: '^[0-9]{1,}.*', regex: true} // complex, uses regex
              ]
              

              AND the list/array can be a MIX of those things,

              and the string test is the test string is SOMEWHERE in the title, doesn’t have to BE the entire title

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              A 1 Reply Last reply Reply Quote 0
              • A Offline
                AndyHazz Project Sponsor @sdetweil
                last edited by

                @sdetweil fair enough, complexity no doubt warranted!

                Perhaps is there any reason why shouldEventBeExcluded function might not be getting called at all for me? I’m stumped why after making all these changes including console.log messages, nothing is appearing any different -

                S 3 Replies Last reply Reply Quote 0
                • S Offline
                  sdetweil @AndyHazz
                  last edited by

                  @AndyHazz can’t think of any, MM is case sensitive, some times people get the case wrong and we don’t report unexpected parms or missing parms…

                  but you’ve been using that so, it doesn’t shouldn’t be an issue for you

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

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

                    @AndyHazz I copied your post in exactly, i reverted back to 2.32 original first

                    and got the right debug and results

                    [2025-07-09 16:27:38.473] [DEBUG] Processing entry…
                    [2025-07-09 16:27:38.473] [DEBUG] title: Dad’s Birthday
                    [2025-07-09 16:27:38.473] [LOG] should be excluded dad’s birthday birthday false g
                    [2025-07-09 16:27:38.473] [LOG] event should be excluded = true, dad’s birthday
                    [2025-07-09 16:27:38.473] [LOG] filter applies result = { excluded: true, until: null }
                    [2025-07-09 16:27:38.473] [LOG] filter applies returning = { excluded: true, until: null }

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

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

                      @AndyHazz and

                      the fetcherutils processes this exclude list very early after getting the events parsed

                                      // loop thru the parsed data, one event at a time
                      		Object.entries(data).forEach(([key, event]) => {
                      			Log.debug("Processing entry...");
                      
                      			const title = CalendarFetcherUtils.getTitleFromEvent(event);
                      			Log.debug(`title: ${title}`);
                      
                      			// Return quickly if event should be excluded.
                      			let { excluded, eventFilterUntil } = this.shouldEventBeExcluded(config, title);
                      			if (excluded) {
                      				return;
                      			}
                      

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      A 1 Reply Last reply Reply Quote 0
                      • A Offline
                        AndyHazz Project Sponsor @sdetweil
                        last edited by

                        @sdetweil should I see a console message from loader.js about calendarfetcherutils.js being loaded?

                        I see

                        Load script: modules/default/calendar/calendar.js
                        Load script: modules/default/calendar/calendarutils.js
                        

                        but no mention in the console of calendarfetcherutils.js

                        S 1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 3
                        • 4
                        • 5
                        • 3 / 5
                        • 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