-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmyhome-debug.js
31 lines (26 loc) · 883 Bytes
/
myhome-debug.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
module.exports = function(RED) {
let myhome = require('./myhome-utils');
function MyHomeDebugNode(config) {
RED.nodes.createNode(this,config);
var node = this,
gateway = RED.nodes.getNode(config.gateway)
this.on('input', function(msg) {
var mhengine = new myhome.engine(gateway)
mhengine.sendCommand({
command:msg.payload,
stopon: ['*#*1##', '*#*0##'],
done: function(pkt,i) {
var m = pkt.match(/\*#\*(\d)##/);
var successFail = m[1];
}
});
});
this.on("close", function() {
console.log('debug end called')
// Called when the node is shutdown - eg on redeploy.
// Allows ports to be closed, connections dropped etc.
// eg: node.client.disconnect();
});
}
RED.nodes.registerType("myhome-debug", MyHomeDebugNode);
}