• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

Show calendar based on IP Address accessed

Scheduled Pinned Locked Moved Development
68 Posts 3 Posters 17.8k 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.
  • S Offline
    Spinster @MMRIZE
    last edited by May 7, 2024, 1:44 PM

    @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

    M 1 Reply Last reply May 7, 2024, 1:59 PM Reply Quote 0
    • S Offline
      Spinster @sdetweil
      last edited by May 7, 2024, 1:57 PM

      @sdetweil Is this working? Should I try it, please advice

      S 1 Reply Last reply May 7, 2024, 2:01 PM Reply Quote 0
      • M Offline
        MMRIZE @sdetweil
        last edited by MMRIZE May 7, 2024, 2:00 PM May 7, 2024, 1:57 PM

        @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.

        1 Reply Last reply Reply Quote 0
        • M Offline
          MMRIZE @Spinster
          last edited by MMRIZE May 7, 2024, 2:00 PM May 7, 2024, 1:59 PM

          @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",
          			},
          
          ...
          
          S 3 Replies Last reply May 7, 2024, 2:14 PM Reply Quote 0
          • S Away
            sdetweil @Spinster
            last edited by May 7, 2024, 2:01 PM

            @Spinster yes, the two pieces together

            ipaddress:“…”
            at each cal url block… only does one ipaddress per url

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            S 1 Reply Last reply May 7, 2024, 2:53 PM Reply Quote 0
            • S Offline
              Spinster @MMRIZE
              last edited by May 7, 2024, 2:14 PM

              @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

              1 Reply Last reply Reply Quote 0
              • S Offline
                Spinster @MMRIZE
                last edited by May 7, 2024, 2:30 PM

                @MMRIZE I even added the calendarmap, I hope you seen my config.js sent earlier

                S 1 Reply Last reply May 7, 2024, 2:51 PM Reply Quote 0
                • S Offline
                  Spinster @Spinster
                  last edited by May 7, 2024, 2:51 PM

                  @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

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    Spinster @sdetweil
                    last edited by May 7, 2024, 2:53 PM

                    @sdetweil

                    Should I use your earlier code and this? Please advise

                    S 1 Reply Last reply May 7, 2024, 2:58 PM Reply Quote 0
                    • S Away
                      sdetweil @Spinster
                      last edited by May 7, 2024, 2:58 PM

                      @Spinster yes you need both

                      I am away from my system for another couple hours

                      will collapse to one post then

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      S 1 Reply Last reply May 7, 2024, 5:29 PM Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 5
                      • 6
                      • 7
                      • 4 / 7
                      4 / 7
                      • First post
                        34/68
                        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