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

How do notifications work?

Scheduled Pinned Locked Moved Troubleshooting
notificationsbuttonprofileswticher
11 Posts 4 Posters 9.0k 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.
  • ? Offline
    A Former User
    last edited by A Former User Jul 11, 2017, 2:31 PM Jul 11, 2017, 2:29 PM

    Basically, the real-world notification usages are not centralized by MM. MM provides only protocol.
    So, if you want to use other module’s notifications, first you should know which notifications could be available in the module.
    Some modules are never using notifications. Some module only broadcasts. Some only listens. A few can send and receive. There is no rule,
    By example, If you want to order other module to sleep, there is no notification to do that. Why there is no MSG_SLEEP_YOURSELF? I don’t know. I believe it shoude have been, but not.

    Therefore, when you want to control some module’s fuction externally, first you should read the manual or source codes to find which notifications are available, oterwise you can request the module developer to add specific notifications.

    1 Reply Last reply Reply Quote 0
    • ? Offline
      A Former User
      last edited by Jul 11, 2017, 2:42 PM

      In real-world, hide and show other module mechanism is not lying on the notification system.
      All the modules which are able to hide and sleep others use MM.hide()and .show() methods. There is no implement about delegation for those action to target module. So, controlling other module with notification is just ideal thing until real implements are provided.

      1 Reply Last reply Reply Quote 0
      • ? Offline
        A Former User
        last edited by Jul 11, 2017, 3:14 PM

        Finally, let’s see how to make showing module one by one by pressing button.
        The easist way is to make your module by your self, not a joke.
        MMM-Button only broadcasts BTN_PRESSED message. And MMM-ProfileSwitcher doesn’t understand that message. Therefore if you want to use these two modules, you should modify both of them to send and receive proper Message and payload to carry profile informations. That modification is ideally equal to make it from scratch by yourself.

        1 Reply Last reply Reply Quote 0
        • J Offline
          j.e.f.f Project Sponsor Module Developer @Sruc91
          last edited by Jul 11, 2017, 3:17 PM

          @Sruc91 I’m doing something similar. Take a look at the MMM-Buttons module to see how to capture the button press and send notifications, and then take a look at MMM-Profile switcher to see how it receives notifications.

          In my case, I modified MMM-ProfileSwitcher to receive a “CYCLE_PROFILE” notification that cycles through a list of configured profiles. PM me and I can send you my modified version.

          1 Reply Last reply Reply Quote 0
          • S Offline
            Sruc91
            last edited by Jul 11, 2017, 5:33 PM

            @Sean That does make sense, thank you. In some modules’ descriptions they are just mentioned but no indication on how one should use them.

            @j-e-f-f So I see that in the MMM-Buttons module the notifications are defined in the config file and you can use the needed payload to send information.

            So if I understand correctly, if I send a notification from MMM-Buttons like so:

            this.sendNotification('CURRENT_PROFILE', 'DESIRED_PROFILE_NAME_HERE');
            

            Do I just send the desired notification with the payload of the desired profile and the ProfileSwitcher will understand it?

            ? J 2 Replies Last reply Jul 11, 2017, 6:01 PM Reply Quote 0
            • ? Offline
              A Former User @Sruc91
              last edited by A Former User Jul 11, 2017, 6:14 PM Jul 11, 2017, 6:01 PM

              @Sruc91 as i know, you are right.
              Or you can build your ‘translator’ module which send CURRENT_PROFILE message when BTN_PRESSED message is coming between btn module and prflswtchr module… Its better to keep original legacy codes.

              1 Reply Last reply Reply Quote 0
              • J Offline
                j.e.f.f Project Sponsor Module Developer @Sruc91
                last edited by Jul 11, 2017, 6:52 PM

                @Sruc91 well yeah, but the way MMM-Buttons works, it would send the same payload each time. So if you configured the button press to send the notification ‘CURRENT_PROFILE’ with the payload ‘Jeff’, each button press would be a request to show Jeff’s profile.

                So you need something that always receives the same notification/payload pair to do something different each time with it. That’s what my modification to ‘MMM-ProfileSwitcher’ does, or you can do as @Sean says and write another module to keep track of which profile is next and relay the ‘CURRENT_PROFILE’ notification to the MMM-ProfileSwitcher.

                1 Reply Last reply Reply Quote 0
                • S Offline
                  Sruc91
                  last edited by Jul 12, 2017, 9:33 AM

                  @j-e-f-f That makes sense, thank you very much.

                  Is there any way that I can track those notifications? Like for example, if I send a notification with the MMM-Buttons, is it registered anyway that I can check?

                  J C 2 Replies Last reply Jul 12, 2017, 11:03 AM Reply Quote 0
                  • J Offline
                    j.e.f.f Project Sponsor Module Developer @Sruc91
                    last edited by Jul 12, 2017, 11:03 AM

                    @Sruc91 you’ll see output in Electron’s console when the event is broadcast.

                    1 Reply Last reply Reply Quote 0
                    • C Offline
                      cowboysdude Module Developer @Sruc91
                      last edited by Jul 12, 2017, 12:44 PM

                      @Sruc91

                      console.log(your output);

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