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 I should note that this property is NOT a sequential limit of days from today

      it is UNIQUE days INCLUDING today
      limitDays:2
      so if there no events til next Thursday, that is the 1st day
      and no events til the following Tuesday, that is the second day

      which is different than event tomorrow and saturday, but only show tomorrow… (2 consecutive days gets today and tomorrow), or two days from NOW gets today/thurs/friday, but still not saturday.

      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 AndyHazz

        @sdetweil yeah that’s what I was using limitDays for and it was working great for my needs until now - I have my kids school lessons synced to a google calendar, and setting limitDays to 1 used to show the full set of lessons for the day. When they get home from school (all events from the current day are in the past), it automatically showed all of the lessons for the following day. Best thing I’ve ever used MM for! Even highlights PE lessons so they know when to bring kit :)

        For me now, limitDays: 1 just shows the single next event even when there are 6 more events on that day (and if that event is ‘Tutor time’, it displays when it should be hidden).

        I can’t say exactly what version I was on prior to the update but it should have been whatever the previous version was - since I set this up with watchtower in docker I’ve not had to do any manual upgrades.

        Here’s my anonamised calendar config - I have 5 different calendar modules running if that’s likely to be a factor, but this is one that has the config issues:

            {
                module: 'calendar',
                header: 'School day',
                position: 'bottom_right',
                config: {
                    coloredSymbol: true,
                    coloredText: true,
                    showLocation: true,
                    displaySymbol: false,
                    hideTime: true,
                    tableClass: 'medium',
                    flipDateHeaderTitle: true,
                    fade: false,
                    timeFormat: 'absolute',
                    dateFormat: 'ddd',
                    fullDayEventDateFormat: 'ddd',
                    urgency: '0',
                    sliceMultiDayEvents: true,
                    nextDaysRelative: false,
                    limitDays: 1,
                    fetchInterval: '600000',
                    displayRepeatingCountTitle: true,
                    wrapEvents: false,
                    //maxTitleLength: 30,
                    customEvents: [{ keyword: 'Physical Education', symbol: 'volleyball', color: 'Gold' }],
                    excludedEvents: [
                        'Tutor time'
                    ],
                    calendars: [
                        {
                            symbol: 'graduation-cap',
                            url: 'https://calendar.google.com/calendar/ical/REDACTED/basic.ics'
                        }
                    ]
                }
            },
        
        mumblebajM S 2 Replies Last reply Reply Quote 0
        • mumblebajM Offline
          mumblebaj Module Developer @AndyHazz
          last edited by

          @AndyHazz Do you mind sharing your ICS, anonymized off course.

          Check out my modules at: https://github.com/mumblebaj?tab=repositories
          Check my blog-post: https://mumblebaj.xyz/

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

            @AndyHazz found it…

            comparing date AND TIME oops…

            edit modules/default/calendar/calendar.js
            approx line 708
            change the lines marked below with //

            		if (this.config.limitDays > 0) {
            			let newEvents = [];
            			let lastDate = today.clone().subtract(1, "days").startOf('day');  // add .startOf('day'), note dot
            			let days = 0;
            			for (const ev of events) {
            				let eventDate = this.timestampToMoment(ev.startDate).startOf('day'); // add .startOf('day'), note dot
            

            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 nice! Yes that’s fixed the limitDays issue for me …

              Now, how about part 2 of my issue, the excludedEvents config? The first event showing for me is titled ‘Tutor time’ despite that string being excluded. I’ve tried other terms with/without spaces and nothing seems to work to exclude events any more?

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

                @AndyHazz working on it

                Sam

                How to add modules

                learning how to use browser developers window for css changes

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