-
Notifications
You must be signed in to change notification settings - Fork 20
/
node_helper.js
executable file
·38 lines (32 loc) · 1.07 KB
/
node_helper.js
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
'use strict';
const NodeHelper = require('node_helper');
const MirrorMirror = require('./MirrorMirror')
const ModuleNames = require('./ModuleNames.json')
module.exports = NodeHelper.create({
alexa_start: function() {
var self = this
// Setup AWS IoT
MirrorMirror.setup();
// Listener for IoT event
MirrorMirror.onMessage(function(topic, payload) {
if (topic === MirrorMirror.TOPIC_IMAGES || topic === MirrorMirror.TOPIC_TEXT || topic === MirrorMirror.TOPIC_VIDEO) {
self.sendSocketNotification("RESULT", payload);
} else if (topic === MirrorMirror.TOPIC_MODULE) {
let moduleName = payload.moduleName
if (moduleName in ModuleNames) {
moduleName = ModuleNames[moduleName]
}
self.sendSocketNotification("MODULE", {
moduleName: moduleName,
turnOn: payload.turnOn
});
}
});
},
// Subclass socketNotificationReceived received.
socketNotificationReceived: function(notification, payload) {
if (notification === 'ALEXA_START') {
this.alexa_start();
}
}
});