How to use the node-hue-api.locateBridges function in node-hue-api

To help you get started, we’ve selected a few node-hue-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-red / node-red-nodes / hardware / philips_hue / 103-philips_hue.js View on Github external
if (err) throw err;
                    var lights_discovered = JSON.stringify(lights, null, 2);
                    msg2 = { topic:node.topic, payload: { ipaddress:this.gw_ipaddress, lights:lights_discovered} };
                    node.send(msg2);

                });

            });
            
        
        }

        else {
            //set the lamp status
            //first locate the Hue gateway:
            hue.locateBridges(function(err, result) {

                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);
github node-red / node-red-nodes / hardware / hue / 104-hue_manage.js View on Github external
this.on("input", function(msg){
        var myMsg = msg;
        //set the lamp status
        if (this.gw_ipaddress) {
            setLights(node, myMsg);
        } else {
            //first locate the Hue gateway:
            hue.locateBridges(function(err, result) {


                if (err) { throw err; }
                //check for found bridges
                if(result[0]!=null) {
                    //save the IP address of the 1st bridge found
                    this.gw_ipaddress = result[0].ipaddress;
                    setLights(node, myMsg);
                }
                else {
                    //bridge not found:
                    var msg = {};
                    msg.payload = "Bridge not found!";
                    node.send(msg);
                }
github node-red / node-red-nodes / hardware / hue / 103-hue_discover.js View on Github external
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; }
            //check for found bridges
            if(result[0]!=null) {
                //save the IP address of the 1st bridge found
                this.gw_ipaddress = result[0].ipaddress;
                msg.payload = this.gw_ipaddress;

                //get light info:
                var api = new HueApi(this.gw_ipaddress, node.username);
                api.lights(function(err, lights) {
                    var msg2 = {};
                    if (err) { throw err; }
                    var lights_discovered = JSON.stringify(lights, null, 2);
                    msg2.topic = "Lights";
                    msg2.payload = lights_discovered;
github node-red / node-red-nodes / hardware / hue_manage / 104-hue_manage.js View on Github external
this.on("input", function(msg){
            //set the lamp status
            //first locate the Hue gateway:
            hue.locateBridges(function(err, result) {

                var msg2 = {};
                msg2.topic = this.topic;
                if (err) throw err;
                //check for found bridges
                if(result[0]!=null) {
                    //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;
                    var state = lightState.create();

                    var status;