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.

    MMM-NotificationTrigger transform payload

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    24 Posts 4 Posters 6.1k Views 4 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.
    • lavolp3L Offline
      lavolp3 Module Developer @corius
      last edited by

      @corius Well to be honest I did not expect it to work from scratch. But I am considering taking this into my own mirror to remind me of taking out the trash. :smiling_face:
      I won’t get it done today.
      If you don’t know how to work on from here I need to ask for your patience, and I’ll have a closer look at it myself in the next days.

      How to troubleshoot modules
      MMM-soccer v2, MMM-AVStock

      S 1 Reply Last reply Reply Quote 0
      • S Do not disturb
        sdetweil @lavolp3
        last edited by sdetweil

        @lavolp3 i am debugging it now

        not making any progress… can’t get the time compare to work

        let now = moment()
        let end = now.add(15, "minutes")
        let event_time=moment(event.startDate)
        if(event_time.isAfter(now) && event_time.isBefore(end))
        

        its 11:53, event starts at 12:00 and ends as 12:15

        so 12:00.isAfter(11:53) should be true, but is false
        and 12:00.isBefore(12:08), should be true,m but is false
        

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • ? Offline
          A Former User
          last edited by

          I think it’s better to build a new module about alerting events by the condition.

          1 Reply Last reply Reply Quote 0
          • C Offline
            corius
            last edited by

            @lavolp3 @sdetweil thank you for the time you have spent so far. I would be happy if someone else has an idea how to implement it. Thanks:smiling_face:

            lavolp3L 1 Reply Last reply Reply Quote 0
            • lavolp3L Offline
              lavolp3 Module Developer @corius
              last edited by lavolp3

              @corius So I tamed the beast but I’m getting the feeling that @Sean is right.

              The following would alert you of the next event every time the calendar sends a calendar_event notification:

              	{
              	  module: "MMM-NotificationTrigger",
              	  config: {
              		triggers:[
              		  {
              			trigger: "CALENDAR_EVENTS",
              			fires: [
              				{
              					fire:"SHOW_ALERT",
              					payload: (payload) => {
              						var testMessage = "";
              						var nextEvent = payload.find(event => event.startDate > moment().format("x"));
              						testMessage = nextEvent.title + " " + moment(nextEvent.startDate, "x").format("HH:mm");
              						return {
              							type: "notification",
              							title: "Next event:",
              							message: testMessage
              						} 
              					},
              				}
              			],
              		  },
              		]
              	  }	
              	}, 
              

              For some yet unknown reason, I am getting this alert 8 times! The alert then vanishes quite shortly after.

              It is a good idea, but what I would do, no, WILL do, is implement a “Notification Alert Function” directly into the calendar module (or into MMM-CalendarExt, if you’re interested, @Sean).
              I think that would be a better way of ontrolling the alert created from a calendar event appearing.

              How to troubleshoot modules
              MMM-soccer v2, MMM-AVStock

              S 1 Reply Last reply Reply Quote 0
              • S Do not disturb
                sdetweil @lavolp3
                last edited by

                @lavolp3 said in MMM-NotificationTrigger transform payload:

                For some yet unknown reason, I am getting this alert 8 times! The alert then vanishes quite shortly after.

                because it still sends an alert notification, with an empty payload

                fire:“SHOW_ALERT”, (always)

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                lavolp3L 1 Reply Last reply Reply Quote 0
                • lavolp3L Offline
                  lavolp3 Module Developer @sdetweil
                  last edited by

                  @sdetweil As far as I understand, it triggers when receiving the CALENDAR_EVENTS noti, and then “fires” a new notification, which is the “SHOW_ALERT” with the new payload.
                  This does not explain to me why it sends the “SHOW_ALERT” noti apparently 8 times in a row.

                  How to troubleshoot modules
                  MMM-soccer v2, MMM-AVStock

                  S 1 Reply Last reply Reply Quote 0
                  • S Do not disturb
                    sdetweil @lavolp3
                    last edited by

                    @lavolp3 cause calendar payload events is an array, fires once per

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

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