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.

    sendNotification help

    Scheduled Pinned Locked Moved Troubleshooting
    6 Posts 2 Posters 1.8k Views 3 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.
    • J Offline
      jasondreher
      last edited by

      I want to be able to send a value to https://github.com/mykle1/MMM-EventHorizon to change the time used in a count down timer. Right now I can make the module hide with…

      this.sendNotification('HIDE_TIMER');
      

      but I cant seem to do much more, how do I change my sendNotification to include a payload to change the date and time in MMM-EventHorizon. I will have to change the notificationReceived in MMM-EventHorizon to I assume…

      S 1 Reply Last reply Reply Quote 0
      • S Offline
        sdetweil @jasondreher
        last edited by sdetweil

        @jasondreher just add the payload on to the api call like this

        this.sendNotification('HIDE_TIMER', payload);
        

        ‘payload’ can be anything… a variable (this.variable_name), a literal(‘some literal string’), a dynamically constructed value (‘some value’ + variable_name + ’ right now ')

        the receiving modules sendNotificationReceived(code, payload, sender) function is responsible for ignoring or processing the payload data according to the shared rules of the sender

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • J Offline
          jasondreher
          last edited by jasondreher

          OK so I change my sendNotification to

          this.sendNotification('SHOW_TIMER','18:25:25');
          

          and the MMM-EventHorizon notificationReceived to

              notificationReceived: function(notification, payload) {
                  if (notification === 'HIDE_TIMER') {
                      this.hide(1000);
                  } else if (notification === 'SHOW_TIMER') {
                      this.show(1000);
                      this.time = payload //I added this
                      this.updateDom();  //I added this
                  }
          
              },
          

          Thinking the paylaod will update the countdown time but it does nothing… Not sure what I am doing worng. I have tested this quite a few different ways and searched quite a bit…

          I can tell its doing something as it flickers (like it is refreshing with the updateDom) but the countdown does not reflect the new time.

          S 1 Reply Last reply Reply Quote 0
          • S Offline
            sdetweil @jasondreher
            last edited by

            @jasondreher you didn’t use the payload. Just hide and show. I don’t know the other module.

            But I would guess u need to start a timer with some elapsed time til the action (from now)

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • J Offline
              jasondreher
              last edited by

              @jasondreher said in sendNotification help:

              this.time = payload

              I added “this.time = payload”, this is using the payload correct?

              1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil
                last edited by

                @jasondreher said in sendNotification help:

                this.time = payload

                probably

                this.config.time = payload
                

                Sam

                How to add modules

                learning how to use browser developers window for css changes

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