diff --git a/node-red-contrib-xiaomi-all/xiaomi-all.html b/node-red-contrib-xiaomi-all/xiaomi-all.html index b1c6289..f01c579 100644 --- a/node-red-contrib-xiaomi-all/xiaomi-all.html +++ b/node-red-contrib-xiaomi-all/xiaomi-all.html @@ -4,7 +4,9 @@ color: '#3FADB5', defaults: { gateway: {value:"", type:"xiaomi-configurator"}, - name: {value: ""} + name: {value: ""}, + onlyModels: {value: []}, + excludedSids: { value: []} }, inputs: 1, outputs: 1, @@ -13,6 +15,44 @@ icon: "mi-all.png", label: function () { return this.name || "xiaomi-all"; + }, + oneditprepare: function() { + var node = this; + + function changeGateway(gateway, onlyModels, excludedSids) { + var configNodeID = gateway || $('#node-input-gateway').val(); + if (configNodeID) { + var configNode = RED.nodes.node(configNodeID); + if(configNode) { + onlyModels = onlyModels || $('#node-input-onlyModels').val() || []; + excludedSids = excludedSids || $('#node-input-excludedSids').val() || []; + $('#node-input-excludedSids').empty(); + for (key in configNode.deviceList) { + var device = configNode.deviceList[key]; + if (onlyModels.length == 0 || onlyModels.indexOf(device.model) >= 0) { + var option = $(''); + if(excludedSids && excludedSids.indexOf(device.sid) >= 0) { + option.prop('selected', true); + } + $('#node-input-excludedSids').append(option); + } + } + } + } + } + + changeGateway(this.gateway, this.onlyModels, this.excludedSids); + $("#node-input-gateway, #node-input-onlyModels").change(function () { + changeGateway(); + }); + }, + oneditsave: function() { + if(!$('#node-input-onlyModels').val()) { + this.onlyModels = []; + } + if(!$('#node-input-excludedSids').val()) { + this.excludedSids = []; + } } }); @@ -26,11 +66,35 @@ +
+
Filters
+
+ + +
+
+ + +