mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
lots of little node edits to clean up jsHint "errors"
This commit is contained in:
@@ -40,17 +40,17 @@ function HueNodeDiscovery(n) {
|
||||
|
||||
//get username from user input
|
||||
this.username = n.username;
|
||||
|
||||
|
||||
|
||||
// Store local copies of the node configuration (as defined in the .html)
|
||||
this.topic = n.topic;
|
||||
|
||||
this.on("input", function(msg){
|
||||
|
||||
|
||||
//start with detecting the IP address of the Hue gateway in the local network:
|
||||
hue.locateBridges(function(err, result) {
|
||||
var msg = {};
|
||||
if (err) throw err;
|
||||
if (err) { throw err; }
|
||||
//check for found bridges
|
||||
if(result[0]!=null) {
|
||||
//save the IP address of the 1st bridge found
|
||||
@@ -61,17 +61,16 @@ function HueNodeDiscovery(n) {
|
||||
var api = new HueApi(this.gw_ipaddress, node.username);
|
||||
api.lights(function(err, lights) {
|
||||
var msg2 = {};
|
||||
if (err) throw err;
|
||||
if (err) { throw err; }
|
||||
var lights_discovered = JSON.stringify(lights, null, 2);
|
||||
msg2.topic = "Lights";
|
||||
msg2.payload = lights_discovered;
|
||||
node.send([msg, msg2]);
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
//bridge not found:
|
||||
var msg = {};
|
||||
msg = {};
|
||||
msg.payload = "Bridge not found!";
|
||||
node.send(msg);
|
||||
}
|
||||
@@ -102,4 +101,4 @@ var displayError = function(err) {
|
||||
|
||||
// Register the node by name. This must be called before overriding any of the
|
||||
// Node functions.
|
||||
RED.nodes.registerType("Discover",HueNodeDiscovery);
|
||||
RED.nodes.registerType("Discover",HueNodeDiscovery);
|
||||
|
@@ -91,16 +91,18 @@ function setLights(node, myMsg) {
|
||||
}
|
||||
else {
|
||||
//set lamp according to node settings
|
||||
if(node.lamp_status=="ON")
|
||||
if(node.lamp_status=="ON") {
|
||||
api.setLightState(node.lamp_id, state.on().rgb(hexToRgb(node.color).r,hexToRgb(node.color).g,hexToRgb(node.color).b).brightness(node.brightness)).then(displayResult).fail(displayError).done();
|
||||
else
|
||||
} else {
|
||||
api.setLightState(node.lamp_id, state.off()).then(displayResult).fail(displayError).done();
|
||||
}
|
||||
}
|
||||
|
||||
if(lamp!=-1)
|
||||
if(lamp!=-1) {
|
||||
msg2.payload = 'Light with ID: '+lamp+ ' was set to '+myMsg.payload;
|
||||
else
|
||||
} else {
|
||||
msg2.payload = 'Light with ID: '+node.lamp_id+ ' was set to '+node.lamp_status;
|
||||
}
|
||||
node.send(msg2);
|
||||
}
|
||||
|
||||
@@ -138,7 +140,7 @@ function HueNode(n) {
|
||||
hue.locateBridges(function(err, result) {
|
||||
|
||||
|
||||
if (err) throw err;
|
||||
if (err) { throw err; }
|
||||
//check for found bridges
|
||||
if(result[0]!=null) {
|
||||
//save the IP address of the 1st bridge found
|
||||
|
Reference in New Issue
Block a user