lots of little node edits to clean up jsHint "errors"

This commit is contained in:
dceejay
2015-03-26 18:55:03 +00:00
parent 8eca22bdc3
commit d511ee69fb
18 changed files with 478 additions and 328 deletions

View File

@@ -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);

View File

@@ -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