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.

    CalendarExt3 eventTransformer and refreshInterval

    Scheduled Pinned Locked Moved Solved Troubleshooting
    4 Posts 3 Posters 555 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.
    • F Offline
      fXtra
      last edited by sdetweil

      Hello everyone,

      I am using a Raspberry Pi 5 with the latest MM version and the latest version of the MMM-CalendarExt3 module.

      I would like to display the garbage emptying which works so far. Unfortunately, the ics feed in the title provides all the different garbage cans that are emptied, e.g.:

      {
          "title": "Restmülltonne, Biotonne, Altpapiertonne, Gelbe Tonne",
      }
      

      My goal was to display icons in different colors in the title.

      In detail:
      Restmülltonne = Black garbage icon
      Biotonne = Brown garbage icon
      Altpapiertonne = Blue garbage icon
      Gelbe Tonne = Yellow garbage icon

      This also works so far, but when the refreshInterval of the MMM-CalendarExt3 takes effect, the eventTransformer is apparently no longer executed correctly in my case.

      Here is a shortened version of the configuration with which you can recreate the problem:

      let config = {
          address: "0.0.0.0",
          port: 8080,
          basePath: "/",
          ipWhitelist: [],
          useHttps: false,
          httpsPrivateKey: "",
          httpsCertificate: "",
          language: "de",
          locale: "de-DE",
          logLevel: ["INFO", "LOG", "WARN", "ERROR"],
          timeFormat: 24,
          units: "metric",
          modules: [
      
              // ***** CALENDAR MODULES *****
              {
                  module: "MMM-CalendarExt3",
                  position: "top_bar",
                  config: {
                      firstDayOfWeek: 1,
                      refreshInterval: 6000,
                      weeksInView: 4,
                      useMarquee: true,
                      maxEventLines: 4,
                      customHeader: false,
                      eventFilter: (ev) => {
                          if (ev.calendarName === "Trash") {
                              let relevantTitles = ["Restmülltonne", "Biotonne", "Gelbe Tonne", "Blaue Tonne"];
                              return relevantTitles.some(title => ev.title.includes(title));
                          }
                          return true;
                      },
                      eventTransformer: (ev) => {
                          if (ev.calendarName === "Trash") {
                              const trash = [];
                              const strArray = ev.description.split(',').map(item => item.trim());
                              console.log(ev)
                              for (let item of strArray) {
                                  if (item === "Restmülltonne") trash.push("fa-solid fa-trash trash-black");
                                  else if (item === "Biotonne") trash.push("fa-solid fa-trash trash-brown");
                                  else if (item === "Gelbe Tonne") trash.push("fa-solid fa-trash trash-yellow");
                                  else if (item === "Altpapiertonne") trash.push("fa-solid fa-trash trash-blue");
                              }
      
                              ev.description = trash.join(', ');
                              ev.symbol = trash;
                              if (trash.length === 0) {
                                  ev.symbol = [];
                                  ev.color = "none";
                              }
                          }
                          return ev;
                      }
                  }
              },
              {
                  module: "calendar",
                  header: "Termine",
                  config: {
                      broadcastPastEvents: true,
                      maximumEntries: 10000,
                      calendars: [
                          {
                              name: "Trash",
                              fetchInterval: 3000,
                              useSymbol: false,
                              url: "webcal://-849/feed.ics",
                              color: "none"
                          },
                      ]
                  }
              },
          ]
      };
      
      /*************** DO NOT EDIT THE LINE BELOW ***************/
      if (typeof module !== "undefined") {
          module.exports = config;
      }
      

      Does anyone have any ideas or is there perhaps a better way to solve the problem?

      Thanks in advance

      S C 2 Replies Last reply Reply Quote 0
      • S Do not disturb
        sdetweil @fXtra
        last edited by sdetweil

        @fXtra i edited your post to remove most of the calendar url

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • C Offline
          chrisfr1976 @fXtra
          last edited by

          @fXtra
          This is my code in ext3 config and it does its job:

          			eventTransformer: (ev) => {
          			    if (ev.title.search('Altpapier') > -1) {
          			        ev.color = 'blue';
          			        ev.symbol = ['noto:rolled-up-newspaper'];
          			    }
          			    if (ev.title.search('LVP') > -1) {
          			        ev.color = 'yellow';
          			        ev.symbol = ['noto:recycling-symbol'];
          			    }
          			    if (ev.title.search('Biotonne') > -1) {
          			        ev.color = 'brown';
          			        ev.symbol = ['noto:biohazard'];
          			    }
          			    if (ev.title.search('Restmüll') > -1) {
          			        ev.color = 'gray';
          			        ev.symbol = ['noto:squinting-face-with-tongue'];
          			    }
          			    return ev;
          				},
          
          

          Regards, Chris.

          F 1 Reply Last reply Reply Quote 0
          • F Offline
            fXtra @chrisfr1976
            last edited by

            @chrisfr1976
            Thank you for sharing. This helped me it seems it was an issue with my conditions using the ev.title.search(‘string’) solved my issue.

                            eventTransformer: (ev) => {
                                if (ev.calendarName === "Trash") {
                                    const trash = [];
                                    ev.color = 'gray';
            
                                    if (ev.title.search('Altpapiertonne') > -1) {
                                        trash.push("fa-solid fa-trash trash-blue")
                                    }
            
                                    if (ev.title.search('Gelbe Tonne') > -1) {
                                        trash.push("fa-solid fa-trash trash-yellow")
                                    }
            
                                    if (ev.title.search('Biotonne') > -1) {
                                        trash.push("fa-solid fa-trash trash-brown")
                                    }
            
                                    if (ev.title.search('Restmülltonne') > -1) {
                                        trash.push("fa-solid fa-trash trash-black")
                                    }
            
                                    ev.symbol = trash;
                                    if (trash.length === 0) {
                                        ev.symbol = [];
                                        ev.color = "none";
                                    }
                                }
                                return ev;
                            }
                        }
                    }
            

            alt text

            1 Reply Last reply Reply Quote 0
            • F fXtra has marked this topic as solved on

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 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