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

notification array

Scheduled Pinned Locked Moved Troubleshooting
6 Posts 2 Posters 887 Views 2 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.
  • M Offline
    MrDondoT
    last edited by Sep 25, 2019, 12:58 PM

    Re: MMM-NotificationTrigger

    Hello, great module, simple and precise.
    Just one question (I’m not a JS expert), is there any simple way to trigger the notificaion based on an array of triggers?
    eg:

    {
    module: “MMM-NotificationTrigger”,
    config: {
    triggers:[
    {
    trigger: “DOM_OBJECTS_CREATED”,
    fires: [
    {
    fire: [“MY_COMMAND”,“OTHER_COMMAND”,“ANY_COMMAND”],
    exec: “sleep 5; ls -l”
    },
    ],
    },
    ]
    }
    },

    Thanks

    ? 2 Replies Last reply Sep 25, 2019, 2:00 PM Reply Quote 0
    • ? Offline
      A Former User @MrDondoT
      last edited by Sep 25, 2019, 2:00 PM

      @MrDondoT
      But is it too complex?

      fires:[
        {fire: "NOTI_A"},
        {fire: "NOTI_B"},
        {fire: "NOTI_C"},
      ],
      
      
      1 Reply Last reply Reply Quote 0
      • ? Offline
        A Former User @MrDondoT
        last edited by Sep 25, 2019, 2:03 PM

        @MrDondoT
        Or you can do like this tricky way;

        fires: [
          {
            fire: "DUMMY",
            payload: (payload) => {
              MM.getModules().enumerate(module=>{
                if (module.name == "MMM-NotificationTrigger") {
                  module.sendNotification("NOTI_A")
                  module.sendNotification("NOTI_B")
                  module.sendNotification("NOTI_C")
                }
              })
              return null
            }
          }
        ]
        
        1 Reply Last reply Reply Quote 0
        • M Offline
          MrDondoT
          last edited by Sep 25, 2019, 2:40 PM

          Sorry Sean, my bad example! Thank you for reply but in reality I was looking for an array of triggers like so:

          triggers:[
          {
          trigger: [“MY_COMMAND”,“OTHER_COMMAND”,“ANY_COMMAND”],
          fires: [
          {fire: “NOTI_A”},
          ],
          …

          ? 1 Reply Last reply Sep 25, 2019, 3:02 PM Reply Quote 0
          • ? Offline
            A Former User @MrDondoT
            last edited by Sep 25, 2019, 3:02 PM

            @MrDondoT
            You’d better make a new simple module. (Really simple)

            Module.register("MyTriggerModule", {
              notificationReceived: function (notification, payload, sender) {
                const myTriggers = [“MY_COMMAND”,“OTHER_COMMAND”,“ANY_COMMAND”]
                if (myTriggers.include(notification)) {
                  this.sendNotification("MY_NOTIFICATION")
                }
              }
            })
            

            Really that’s all.

            1 Reply Last reply Reply Quote 1
            • M Offline
              MrDondoT
              last edited by Sep 25, 2019, 3:13 PM

              Thanks Sean! I appreciate your help. :thumbs_up_light_skin_tone:

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