Read the statement by Michael Teeuw here.
Show calendar based on IP Address accessed
-
@MMRIZE I tried it, but it is still showing the calendar even if there is no calendar defined for the ip. I edited only the config.js file and added your code. Modified the calendars to suite mine. I could see even if there is no calendar defined for a particular ip. Please advice
-
@sdetweil Is this working? Should I try it, please advice
-
@sdetweil
Still I can’t catch you.[2024-05-07 15:03:33.741] [LOG] Use existing calendarfetcher for url: https://ics.calendarlabs.com/76/mm3137/US_Holidays.ics
The log shows, duplicated URL would be integrated into existing fetcher, So unlike your words, 3 clients doesn’t make 3 duplicated wasted fetcher.
If clientA needs cal1, cal2, cal3 and clientB needs cal1, cal4, cal5. In this case server should fetch 5 calendars anyway. User may need cal1 ~ cal5 even on 1 screen or 2 screens, ther server’s burden would be the same.
The only aspect that could be considered a waste is the transmission of unusing event data for cal4 and cal5 to clientA, but unless it’s a performance issue with the data parsing algorithm, simply having large data size being transmitted isn’t particularly problematic. Moreover, since the data is dropped in my code as soon as the notification is received, it can’t be deemed a significant memory issue. If the data size itself becomes problematic, it implies there’s already a problem with the original calendar module using cal1, cal2, cal3, cal4, and cal5.
Too skeptic.
-
@Spinster said in Show calendar based on IP Address accessed:
Modified the calendars to suite mine. I could see even if there is no calendar defined for a particular ip. Please advice
in the calendar config, I added
clientMap
.{ module: "calendar", header: "US Holidays", position: "top_left", config: { clientMap: { "192.168.178.63": [ "cal1", "cal2", "cal3" ], "192.168.178.22": [ "cal3", "cal4", "cal5" ] }, calendars: [ { url: "...", name: "cal1", }, ...
-
@Spinster yes, the two pieces together
ipaddress:“…”
at each cal url block… only does one ipaddress per url -
@MMRIZE
Here is my config{ module: "alert", }, /* { module: "updatenotification", position: "top_bar" },*/ { module: "clock", position: "top_left" }, { module: "MMM-ModuleMonkeyPatch", config: { patches: [ { module: "calendar", method: "socketNotificationReceived", patch: async function (original, args) { const [ notification, payload ] = args if (notification === "CALENDAR_EVENTS") { const calendarName = this.config.calendars.find((cal) => cal.url === payload?.url)?.name const r = await fetch('http://10.5.11.1:8080/modules/getip') const ip = JSON.parse(await r.text())?.[ 'address' ] ?? null console.log(ip) if (!this.config.clientMap?.[ ip ]?.includes(calendarName)) { return original(notification, { ...payload, events: [] }) } } return original(notification, payload) } } ] } }, { module: "getip", }, { module: "calendar", header: "Home Cal", position: "top_left", config: { clientMap: { "10.5.11.5": [ "cal1" ], "10.5.11.6": ["cal2"] }, calendars: [ { fetchInterval: 10 * 60 * 1000, symbol: "calendar-check", url: "https://homecals/xEzboFt7Kr3Yfiys?export", name: "cal1", } ] } }
This is showing both 10.5.11.5 and 10.5.11.6 the same calendar. Though 10.5.11.6 should not have any calendar since it is not defined. Even I tried without an entry of 10.5.11.6 in calendar map but it still showing the calendar. What am I doing wrong. Please advice
-
@MMRIZE I even added the calendarmap, I hope you seen my config.js sent earlier
-
@Spinster said in Show calendar based on IP Address accessed:
@MMRIZE I even added the calendarmap, I hope you seen my config.js sent earlier
Sorry, i think I have not installed Monkey module, will install and check again
-
Should I use your earlier code and this? Please advise
-
@Spinster yes you need both
I am away from my system for another couple hours
will collapse to one post then