mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Added check for no Philip Hue bridge located
This commit is contained in:
parent
5747dfe25d
commit
d491aa61c9
@ -58,6 +58,7 @@ function HueNode(n) {
|
|||||||
msg.topic = this.topic;
|
msg.topic = this.topic;
|
||||||
|
|
||||||
this.on("input", function(msg){
|
this.on("input", function(msg){
|
||||||
|
|
||||||
//check if users has selected discovery mode, provide output:
|
//check if users has selected discovery mode, provide output:
|
||||||
if(this.discovery_mode==1) {
|
if(this.discovery_mode==1) {
|
||||||
//start with detecting the IP address of the Hue gateway in the local network:
|
//start with detecting the IP address of the Hue gateway in the local network:
|
||||||
@ -95,10 +96,16 @@ function HueNode(n) {
|
|||||||
var msg2 = {};
|
var msg2 = {};
|
||||||
msg2.topic = this.topic;
|
msg2.topic = this.topic;
|
||||||
if (err) throw err;
|
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
|
//save the IP address of the 1st bridge found
|
||||||
this.gw_ipaddress = result[0].ipaddress;
|
this.gw_ipaddress = result[0].ipaddress;
|
||||||
|
|
||||||
|
|
||||||
//set light status
|
//set light status
|
||||||
var api = new HueApi(this.gw_ipaddress, node.username);
|
var api = new HueApi(this.gw_ipaddress, node.username);
|
||||||
var lightState = hue.lightState;
|
var lightState = hue.lightState;
|
||||||
@ -124,6 +131,7 @@ function HueNode(n) {
|
|||||||
|
|
||||||
msg2.payload = 'Light with ID: '+node.lamp_id+ ' was set to '+status;
|
msg2.payload = 'Light with ID: '+node.lamp_id+ ' was set to '+status;
|
||||||
node.send(msg2);
|
node.send(msg2);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user