MagicMirror² v2.13.0 is available! For more information about this release, check out this topic.

notification array



  • 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


  • Module Developer

    @MrDondoT
    But is it too complex?

    fires:[
      {fire: "NOTI_A"},
      {fire: "NOTI_B"},
      {fire: "NOTI_C"},
    ],
    
    

  • Module Developer

    @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
        }
      }
    ]
    


  • 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”},
    ],


  • Module Developer

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



  • Thanks Sean! I appreciate your help. 👍🏻


Log in to reply