Description:
MMM-NotifCustomActions is a technical module designed to do the glue between modules or do simple JS function.
It reacts on module notifications.
For example, it can send a specific notification to a module or execute a shell command when another module broadcasts a notification.
JS functions can be executed on browser side or on server side (ex: shutdown).
For simple JS code, all can be written in module config; for complex JS functions 2 specific files are automatically loaded and are accessible by the module.
Example of simple configuration
This example does:
- a
shutdown
command (node side) when notificationACTION_SHUTDOWN
is received. - a sent of notification
PAGE_SELECT
with payload"musicPage"
(client side) when notificationSPOTIFY_CONNECTED
is received.
actions: [
{
notification: "ACTION_SHUTDOWN",
action_node: function(self, sender, payload) {
exec("sudo shutdown -h now");
}
},
{
notification: "SPOTIFY_CONNECTED",
action_client: function(self, sender, payload) {
self.sendNotification("PAGE_SELECT", "musicPage");
}
},
]