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

Send Notification from one module to another module

Scheduled Pinned Locked Moved Development
6 Posts 4 Posters 4.7k 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.
  • E Offline
    edubey
    last edited by Feb 6, 2017, 3:50 PM

    I have one module which collects user data from somewhere. Once the data is collected how can I send notification to another module.
    I can use MM.getModules().
    But then How can I send notification.

    In Simple terms: Notify module A from module B
    Thanks in advance

    S 1 Reply Last reply Feb 6, 2017, 4:01 PM Reply Quote 0
    • S Offline
      strawberry 3.141 Project Sponsor Module Developer @edubey
      last edited by Feb 6, 2017, 4:01 PM

      @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 S 3 Replies Last reply Feb 6, 2017, 4:37 PM Reply Quote 3
      • E Offline
        edubey @strawberry 3.141
        last edited by Feb 6, 2017, 4:37 PM

        @strawberry-3.141
        Thanks, i got it

        1 Reply Last reply Reply Quote 0
        • E Offline
          edubey @strawberry 3.141
          last edited by Feb 6, 2017, 4:41 PM

          @strawberry-3.141

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

          Y 1 Reply Last reply Feb 6, 2017, 4:44 PM Reply Quote 0
          • Y Offline
            yawns Moderator @edubey
            last edited by Feb 6, 2017, 4:44 PM

            @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
            • S Offline
              SvenSommer @strawberry 3.141
              last edited by Jul 22, 2017, 12:16 PM

              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