Read the statement by Michael Teeuw here.
How do you get modules to communicate with each other?
-
I’ve seen that it can be done using notifications however i dont really understand how to do so, do you have to write a script of some sort?
The kind of thing im looking to do is have multiple pages using MMM-Pages and for example have a voice recignition module to change page.
I just need the basic idea however as currently i have no idea how to do so.
-
@adrien00 your voice reco module uses a JavaScript function
this.sendNotification(notification_string, optional_data)
in this case u need to send a notification that the MMM-Pages module understands.
the module documents the notifications it understands
-
@sdetweil sorry my laptop stopped working so only just seen this! Where am i writing these commands? In config.js? Do i need to put some sort of if condition in? Also do you know of any exaple codes that show how to do this?
Thanks
-
@adrien00 the source code of the voice module would need to do this.
many modules use this . my MMM-SleepWake does this to tell other modules that we are blanking the screen or waking it up
https://github.com/sdetweil/MMM-SleepWake
all the default modules send notifications to tell others about the weather, the calendar, alerts, news…
other modules can use the info or ignore it.
sendNotification is a broadcast to all other running modules
-
@sdetweil This is so helpful, thanks!
-
-
@adrien00 I have two modules that relay info back and forth to each other. They are weather modules and I get info and send it over to the other module.
I do this because I needed/wanted some weather info to show up in a specific place so I send my ‘payload’ from the 1st module to the 2nd module…