Added check for no Philip Hue bridge located

This commit is contained in:
Charalampos Doukas 2013-11-09 13:18:04 +01:00
parent 5747dfe25d
commit d491aa61c9
1 changed files with 33 additions and 25 deletions

View File

@ -58,6 +58,7 @@ function HueNode(n) {
msg.topic = this.topic;
this.on("input", function(msg){
//check if users has selected discovery mode, provide output:
if(this.discovery_mode==1) {
//start with detecting the IP address of the Hue gateway in the local network:
@ -95,10 +96,16 @@ function HueNode(n) {
var msg2 = {};
msg2.topic = this.topic;
if (err) throw err;
if(result[0]==null) {
msg2.payload="No Philips Hue Bridge located! Nothing to be done.";
console.log("No Philips Hue Bridge located!");
node.send(msg2);
}
else {
//save the IP address of the 1st bridge found
this.gw_ipaddress = result[0].ipaddress;
//set light status
var api = new HueApi(this.gw_ipaddress, node.username);
var lightState = hue.lightState;
@ -124,6 +131,7 @@ function HueNode(n) {
msg2.payload = 'Light with ID: '+node.lamp_id+ ' was set to '+status;
node.send(msg2);
}
});
}