diff --git a/node-red-contrib-xiaomi-all/xiaomi-all.html b/node-red-contrib-xiaomi-all/xiaomi-all.html index 93046db..e63c67a 100644 --- a/node-red-contrib-xiaomi-all/xiaomi-all.html +++ b/node-red-contrib-xiaomi-all/xiaomi-all.html @@ -1,12 +1,4 @@ diff --git a/node-red-contrib-xiaomi-all/xiaomi-all.js b/node-red-contrib-xiaomi-all/xiaomi-all.js index b6317da..d4262a9 100644 --- a/node-red-contrib-xiaomi-all/xiaomi-all.js +++ b/node-red-contrib-xiaomi-all/xiaomi-all.js @@ -1,15 +1,22 @@ module.exports = (RED) => { - + function getOnlyModelsValue(input) { + var cleanOnlyModels = []; + input.forEach((value) => { + cleanOnlyModels = cleanOnlyModels.concat(value.split(',')); + }); + return cleanOnlyModels; + } function XiaomiAllNode(config) { RED.nodes.createNode(this, config); this.gateway = RED.nodes.getNode(config.gateway); - this.onlyModels = config.onlyModels; + this.onlyModels = getOnlyModelsValue(config.onlyModels || []); this.excludedSids = config.excludedSids; console.log(this.onlyModels); this.isDeviceValid = (device) => { + console.log(device.sid, device.model, this.onlyModels, this.excludeSids); if((!this.onlyModels || this.onlyModels.length == 0) && (!this.excludedSids || this.excludedSids.length == 0)) { return true; } diff --git a/package.json b/package.json index 9097296..14c6322 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-mi-devices", - "version": "1.0.5", + "version": "1.0.6", "description": "A set of nodes to control some of the popular Xiaomi sensors which are connected to the Xiaomi Gateway, and the Gateway itself.", "repository": { "type": "git",