feat(all): add all devices node
This commit is contained in:
22
node-red-contrib-xiaomi-all/xiaomi-all.js
Normal file
22
node-red-contrib-xiaomi-all/xiaomi-all.js
Normal file
@@ -0,0 +1,22 @@
|
||||
module.exports = function(RED) {
|
||||
"use strict";
|
||||
var mustache = require("mustache");
|
||||
var miDevicesUtils = require('../utils');
|
||||
|
||||
function XiaomiAllNode(config) {
|
||||
RED.nodes.createNode(this, config);
|
||||
this.gateway = RED.nodes.getNode(config.gateway);
|
||||
|
||||
var node = this;
|
||||
|
||||
if (this.gateway) {
|
||||
node.on('input', function(msg) {
|
||||
msg.payload = node.gateway.deviceList;
|
||||
node.send(msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
RED.nodes.registerType("xiaomi-all", XiaomiAllNode);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user