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

MMM-NotificationTrigger transform payload

Scheduled Pinned Locked Moved Unsolved Troubleshooting
24 Posts 4 Posters 5.5k 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.
  • L Offline
    lavolp3 Module Developer
    last edited by lavolp3 Jan 14, 2020, 3:41 PM Jan 14, 2020, 3:39 PM

    {
      module: "MMM-NotificationTrigger",
      config: {
        triggers:[
          {
            trigger: "CALENDAR_EVENTS",
            fires: [
              {
                fire:"SHOW_ALERT",
                payload: (payload) => {
                  var testMessage = "";
                  payload.forEach(event => {
                    if (moment(event.startDate) > moment() && moment(event.startDate) < moment().add("15", minutes)) {
                     testMessage += event.title + ", "
                    }
                  });
                  return {
                          type: "notification",
                           title: "test",
                           message: testMessage
                  } 
                },
              },
            ],
          },
        ]
      }
    },
    

    This will most probably not work and needs to be de-bugged, but might be worth as a starting point. And I hope you get what I’m hinting at.

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

    1 Reply Last reply Reply Quote 0
    • L Offline
      lavolp3 Module Developer @corius
      last edited by lavolp3 Jan 14, 2020, 3:42 PM Jan 14, 2020, 3:40 PM

      @corius

      can you please post the code?

      Took me 10 seconds :smiling_face_with_sunglasses:
      No, of course I was already working on it.

      Seriously, I like the idea, that’s why I did a contribution.But you need to be more specific if you want to have the complete solution

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

      C 1 Reply Last reply Jan 14, 2020, 4:25 PM Reply Quote 0
      • C Offline
        corius
        last edited by Jan 14, 2020, 3:59 PM

        @lavolp3 Thank you for the fast answer. I tried this code. the result is that I get a notification but so far it only contains the title (test) but not the massage (title of the calendar event)

        S L 2 Replies Last reply Jan 14, 2020, 4:30 PM Reply Quote 0
        • C Offline
          corius @lavolp3
          last edited by Jan 14, 2020, 4:25 PM

          @lavolp3 what do you mean by “more specific”?

          S 1 Reply Last reply Jan 14, 2020, 4:31 PM Reply Quote 0
          • S Offline
            sdetweil @corius
            last edited by Jan 14, 2020, 4:30 PM

            @corius did u have an event within the next 15 minutes?

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            C 1 Reply Last reply Jan 14, 2020, 4:37 PM Reply Quote 0
            • S Offline
              sdetweil @corius
              last edited by sdetweil Jan 14, 2020, 4:31 PM Jan 14, 2020, 4:31 PM

              @corius >what do you mean by “more specific”?

              all the questions we have been asking… title, time filter, number to show, …

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 0
              • C Offline
                corius @sdetweil
                last edited by Jan 14, 2020, 4:37 PM

                @sdetweil yes i have

                1 Reply Last reply Reply Quote 0
                • L Offline
                  lavolp3 Module Developer @corius
                  last edited by Jan 14, 2020, 4:44 PM

                  @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 Jan 14, 2020, 5:05 PM Reply Quote 0
                  • S Offline
                    sdetweil @lavolp3
                    last edited by sdetweil Jan 14, 2020, 6:01 PM Jan 14, 2020, 5:05 PM

                    @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 Jan 15, 2020, 8:01 AM

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

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