RED.nodes.getNode(tmpNode.id);
- if(tmpNodeInst.ip == bulb.hostname || tmpNodeInst.sid == parseInt(bulb.id)) {
- tmpNodeInst.bulb = bulb;
- }
- }
- });
- });
- });
- }
-
- static get bulbs() {
- return this._bulbs;
- }
-}
\ No newline at end of file
diff --git a/src/nodes/yeelight/YeelightConfigurator.ejs b/src/nodes/yeelight/YeelightConfigurator.ejs
index 0b22dcb..8369171 100644
--- a/src/nodes/yeelight/YeelightConfigurator.ejs
+++ b/src/nodes/yeelight/YeelightConfigurator.ejs
@@ -3,23 +3,22 @@
category: 'config',
defaults: {
name: {value: ""},
- ip: {value: ""},
sid: {value: ""}
},
label: function () {
return this.name || "yeelight conf";
},
oneditprepare: function() {
- RED.settings.miDevicesYeelightConfiguratorDiscoveredBulbs.forEach(function(bulb, index) {
+ var foundBulbs = RED.settings.miDevicesYeelightConfiguratorDiscoveredBulbs;
+ Object.keys(foundBulbs).forEach(function(sid) {
+ var bulb = foundBulbs[sid];
$('#discovered-bulbs').append('');
});
- var node = this;
$('#discovered-bulbs').on('change', function() {
var sid = $('#discovered-bulbs').val();
- var bulb = sid && RED.settings.miDevicesYeelightConfiguratorDiscoveredBulbs.filter(function(e) { return e.sid == sid })[0];
+ var bulb = foundBulbs[sid];
$("#node-config-input-name").val(bulb && bulb.name);
$("#node-config-input-sid").val(bulb && bulb.sid);
- $("#node-config-input-ip").val("");
});
}
});
@@ -37,15 +36,10 @@
-
-
-
-
- Note: use ip or sid - sid is better.