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

CALENDAR_EVENTS not broadcasting? MMM-Calendarweek

Scheduled Pinned Locked Moved Unsolved Troubleshooting
13 Posts 4 Posters 5.1k 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
    Subintro
    last edited by Oct 24, 2018, 7:18 PM

    Hey so I’m trying to make an app do something if it receives the notification ‘CALENDAR_EVENTS’ from the calendar.

    So far its not doing anything. I tried to use the alert module but I get nothing from that either. If MMM-CalendarWeek isnt properly working with broadcasts, is there a way to set up the stock calendar module to work in the background?

    My code is here

    	// Default module config.
    	defaults: {
    		this.hide(),
    	text: "Calendar alert receieved!"
    		
    	},
    	notificationReceived: function(notification, payload, sender) {
    				if (notification === 'CALENDAR_EVENTS') {
    				var x = payload,
    				for (let value of x) {
    					this.show(),
    				var startTime = new Date(startDate),
    				var endTime = new Date(endDate),
    				var ms = (endTime.getTime() - startTime.getTime()) / 1000,
    				setTimeout(function(){
    					this.hide()
    					}, ms),				
    				}
    	        
           }
       },
    
    	// Override dom generator.
    	getDom: function() {
    		var wrapper = document.createElement("div");
    		wrapper.innerHTML = this.config.text;
    		return wrapper;
    	}
    });
    S 1 Reply Last reply Oct 24, 2018, 11:02 PM Reply Quote 0
    • S Offline
      sdetweil @Subintro
      last edited by Oct 24, 2018, 11:02 PM

      @subintro one of my modules depends on the calendar notification and works fine

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      1 Reply Last reply Reply Quote 0
      • S Offline
        Subintro
        last edited by Oct 25, 2018, 12:20 PM

        And you’re using the MMM-Calendarweek module? Does my notificationReceived look like it should be working to you?

        S 1 Reply Last reply Oct 25, 2018, 2:29 PM Reply Quote 0
        • S Offline
          sdetweil @Subintro
          last edited by sdetweil Oct 25, 2018, 2:31 PM Oct 25, 2018, 2:29 PM

          @subintro no, using the default calendar module, and your code looks exactly like mine for handling the event

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • S Offline
            Subintro
            last edited by Oct 25, 2018, 3:30 PM

            @sdetweil Ah darn, I can’t understand why its not working then.

            I’ve put the default calendar module in the background but doesnt seem like its working. I’m lost with this haha.

            Thanks for the help

            1 Reply Last reply Reply Quote 0
            • S Offline
              Subintro
              last edited by Oct 26, 2018, 4:33 PM

              So I’ve updated my code to make it as simple as possible, but I’m still not getting anything.

              I’ve tried adding console.log to my calendar module so when it sends the notification, it logs it so I can see it actually working, but for some reason the calendar breaks when I do that.

              	// Default module config.
              	defaults: {	
              	text: "Notification received!";
              	this.hide;	
              	},
              	notificationReceived:function(notification, payload, sender) {
              				if (notification === 'CALENDAR_EVENTS') {
              					this.show();
              					this.updateDom(); 
                     }
                 },
              

              So I believe this should be working if the calendar events is being sent out.

              Is there any other way I can check the notifications are sending without console.log?

              1 Reply Last reply Reply Quote 0
              • A Offline
                AxLed Module Developer
                last edited by AxLed Oct 26, 2018, 6:16 PM Oct 26, 2018, 6:11 PM

                @Subintro
                If you install the MMM-Remote-Control module you are able to simulate notifications. The link for doing that has to look like: http://IPofYourMM:8080/remote?action=NOTIFICATION& notification=CALENDAR_EVENTS

                I would also put a console.log before your

                this.show();
                

                in your code:

                if (notification === 'CALENDAR_EVENTS') {
                   console.log("Calenderevent received.");
                   this.show();
                   this.updateDom(); 
                 }
                

                AxLED

                1 Reply Last reply Reply Quote 0
                • S Offline
                  sdetweil
                  last edited by Oct 26, 2018, 7:29 PM

                  You should use Log.log() in the module instead of console.log()…

                  Then open the debug console, ctrl-shift-i letter i)… select the console tab

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    Subintro
                    last edited by Oct 26, 2018, 8:38 PM

                    @axled said in CALENDAR_EVENTS not broadcasting? MMM-Calendarweek:

                    console.log(“Calenderevent received.”);

                    Oh man this has been massive help. Looks like my module isnt receiving notifications at all. Time to figure it out

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      Subintro
                      last edited by Oct 26, 2018, 8:54 PM

                      Man I think I misunderstood how the broadcast events works, I was understanding that when an event started, it broadcasted that one event as it started. I was hoping I could make a pop-up notification system for when an event starts, and disappear when it ends.

                      Thats what it seems like looking at the calendar console logs

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