Read the statement by Michael Teeuw here.
CalendarExt3 eventTransformer and refreshInterval
-
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 iconThis 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
-
@fXtra i edited your post to remove most of the calendar url
-
@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; }, -
@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; } } } -
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