refactor: code clean up
This commit is contained in:
@@ -40,4 +40,13 @@
|
||||
</dl>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<h4>Details</h4>
|
||||
<p>Sample payload:</p>
|
||||
<p><pre>[
|
||||
{sid: "128d0901db1fa8", desc: "Door sensor" model: "magnet"},
|
||||
{sid: "151d0401ab2491", desc: "Heat sensor", model: "sensor_ht"},
|
||||
{sid: "658d030171427c", desc: "Button", model: "switch"}
|
||||
]</pre>
|
||||
</p>
|
||||
</script>
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
module.exports = function(RED) {
|
||||
"use strict";
|
||||
var mustache = require("mustache");
|
||||
var miDevicesUtils = require('../utils');
|
||||
|
||||
module.exports = (RED) => {
|
||||
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);
|
||||
this.on('input', (msg) => {
|
||||
msg.payload = this.gateway.deviceList;
|
||||
this.send(msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user