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.

    Send Notification from one module to another module

    Scheduled Pinned Locked Moved Development
    6 Posts 4 Posters 4.9k 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.
    • strawberry 3.141S Offline
      strawberry 3.141 Project Sponsor Module Developer @edubey
      last edited by

      @edubey
      modula

      this.sendNotification("NEW_STUFF", {foo: "bar"});
      

      modulb

      notificationReceived: function(notification, payload, sender){
        if(notification === "NEW_STUFF" && sender === "modula"){
          //handle the payload: {foo: "bar"}
        }
      }
      

      Please create a github issue if you need help, so I can keep track

      E SvenSommerS 3 Replies Last reply Reply Quote 3
      • E Offline
        edubey @strawberry 3.141
        last edited by

        @strawberry-3.141
        Thanks, i got it

        1 Reply Last reply Reply Quote 0
        • E Offline
          edubey @strawberry 3.141
          last edited by

          @strawberry-3.141

          Okay, so its more of a broadcast to all modules, not to any specific…right?

          yawnsY 1 Reply Last reply Reply Quote 0
          • yawnsY Offline
            yawns Moderator @edubey
            last edited by

            @edubey said in Send Notification from one module to another module:

            @strawberry-3.141

            Okay, so its more of a broadcast to all modules, not to any specific…right?

            That’s right. This command sends out a broadcast to all modules. As long as you use a broadcast notification no other module reacts on you don’t have any trouble.

            1 Reply Last reply Reply Quote 0
            • SvenSommerS Offline
              SvenSommer @strawberry 3.141
              last edited by

              It seemed the sender is now a object not only a string with several properties. Therefore this code snippet has changed a little by sender to sender.name:

              notificationReceived: function(notification, payload, sender){
                if(notification === "NEW_STUFF" && sender.name === "modula"){
                  //handle the payload: {foo: "bar"}
                }
              }
              

              Looking for some building inspiration?
              Check out my large, thin and metal framed mirror on robstechlog.com.

              Modules released:
              MMM-GoogleAnalytics
              MMM-GrafanaChart
              MMM-GrafanaGauges

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