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.

    Calendar Module Error with Many Google Calendars

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    15 Posts 3 Posters 1.9k Views 3 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.
    • M Offline
      moorevineyard @sdetweil
      last edited by

      @sdetweil

      I definitely agree that 2 minutes is too short for normal operations.

      In my examples above, I was setting low times for troubleshooting purposes. I’m expecting to set the fetchInterval to about 24 hours once everything is set up the way I want. But this bug still causes lots of problems.

      In particular:

      For a new user that is frequently changing settings and styles, every change would require waiting a significant period of time before being able to check if it is acceptable. In my case, it means waiting a full day to see any calendar events again if I want to change the colors of one calendar.

      Over time, events or calendars may be added by mistake. As far as I know, the normal way to refresh everything is to restart MagicMirror. Again, in this case, removing something that I do t want displayed means that I can’t see other events for a full day.

      Is there another method of refreshing calendar data that would be less disruptive?

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

        @moorevineyard you can set the fetch interval by url too

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • M Offline
          moorevineyard
          last edited by

          I did some more testing and it appears that there may be some sort of rate limit with Google. I haven’t been able to find anything published, but slowing down the fetch process seems to fix the problem.

          I’m not super great with JavaScript and don’t know anything about NodeJS, but this is what I did. In the calendar.js file, starting in line 121 and then down around line 158 I changed the following:

                          this.config.calendars.forEach((calendar, index) => {  // added index
                                  calendar.url = calendar.url.replace("webcal://", "http://");
          
                                  const calendarConfig = {
                                          maximumEntries: calendar.maximumEntries,
                                          maximumNumberOfDays: calendar.maximumNumberOfDays,
                                          pastDaysCount: calendar.pastDaysCount,
                                          broadcastPastEvents: calendar.broadcastPastEvents,
                                          selfSignedCert: calendar.selfSignedCert,
                                          excludedEvents: calendar.excludedEvents,
                                          fetchInterval: calendar.fetchInterval
                                  };
          
                                  if (typeof calendar.symbolClass === "undefined" || calendar.symbolClass === null) {
                                          calendarConfig.symbolClass = "";
                                  }
                                  if (typeof calendar.titleClass === "undefined" || calendar.titleClass === null) {
                                          calendarConfig.titleClass = "";
                                  }
                                  if (typeof calendar.timeClass === "undefined" || calendar.timeClass === null) {
                                          calendarConfig.timeClass = "";
                                  }
          
                                  // we check user and password here for backwards compatibility with old configs
                                  if (calendar.user && calendar.pass) {
                                          Log.warn("Deprecation warning: Please update your calendar authentication configuration.");
                                          Log.warn("https://docs.magicmirror.builders/modules/calendar.html#configuration-options");
                                          calendar.auth = {
                                                  user: calendar.user,
                                                  pass: calendar.pass
                                          };
                                  }
          
                                  /*
                                   * tell helper to start a fetcher for this calendar
                                   * fetcher till cycle
                                   */
          setTimeout(() => {             // added
                                  this.addCalendar(calendar.url, calendar.auth, calendarConfig);
          }, index * 5000);  // 5-second delay for each calendar
                          });
          
          

          This appears to add a 5 second delay to each of the fetches (one fetch occurs every 5 seconds during startup). I added a couple random calendars and now up to 11 seems to work without a problem.

          Is it worth adding a configuration option to introduce the delay? Is Github the best place to make these kinds of suggestions?

          S 2 Replies Last reply Reply Quote 0
          • S Offline
            sdetweil @moorevineyard
            last edited by sdetweil

            @moorevineyard yes, github

            you could create a pull request with the code solution
            maybe just do it if the count is over 4 ?

            11*5 = 55 seconds, almost a minute before some calendars display. Some would not like any delay

            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 @moorevineyard
              last edited by sdetweil

              @moorevineyard would you be willing to test a different fix?

              due to some other problems, I added an increased timeout on the fetch function for any node helper using fetch .

              I’m interested it if fixes your timeout problem (I set timeout to 30 seconds, but can be extended with an environment variable)…
              pull request https://github.com/MagicMirrorOrg/MagicMirror/pull/3660

              git branch to see what branch you are on // remember that name (with *)
              git status to see if any changed files exist(I think yes on calendar)
              git stash if any changed files

              AND we need a newer version of node js
              node -v
              which n
              if ( which n returns nothing do , sudo npm install n -g)
              then
              sudo n 20.18.1

              to use that and not break your existing system

              in the MagicMirror folder

              git stash
              git fetch origin pull/3660/head:test_timeout
              git switch test_timeout
              npm run install-mm
              

              then run your system

              to go back, in the MagicMirror folder

              git checkout original branch name
              git stash pop 
              sudo n 20.9.0
              npm run install-mm
              

              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

                @moorevineyard new MagicMirror version released. be careful to not lose your changes til after you test

                Sam

                How to add modules

                learning how to use browser developers window for css changes

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