This repository was archived by the owner on Jan 24, 2026. It is now read-only.
forked from JHWelch/MMM-GrocyLists
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_helper.js
More file actions
50 lines (40 loc) · 1.34 KB
/
node_helper.js
File metadata and controls
50 lines (40 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Magic Mirror
* Node Helper: MMM-GrocyLists
*
* By Jordan Welch
* MIT Licensed.
*/
const NodeHelper = require('node_helper');
module.exports = NodeHelper.create({
// Override socketNotificationReceived method.
/* socketNotificationReceived(notification, payload)
* This method is called when a socket notification arrives.
*
* argument notification string - The identifier of the noitication.
* argument payload mixed - The payload of the notification.
*/
socketNotificationReceived(notification, payload) {
if (notification === 'MMM-GrocyLists-NOTIFICATION_TEST') {
console.log('Working notification system. Notification:', notification, 'payload: ', payload);
// Send notification
this.sendNotificationTest(this.anotherFunction()); // Is possible send objects :)
}
},
// Example function send notification test
sendNotificationTest(payload) {
this.sendSocketNotification('MMM-GrocyLists-NOTIFICATION_TEST', payload);
},
// this you can create extra routes for your module
extraRoutes() {
const self = this;
this.expressApp.get('/MMM-GrocyLists/extra_route', (req, res) => {
// call another function
values = self.anotherFunction();
res.send(values);
});
},
// Test another function
anotherFunction() {
return { date: new Date() };
},
});