How to use the node-hue-api.nupnpSearch 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 tlackemann / hubert / src / hue.js View on Github external
return new Promise((res, rej) => {
    hue.nupnpSearch((err, result) => {
      if (err) {
        log.error('An error occurred fetching bridges from Hue: %s', err)
        return rej(err);
      }

      // Get the first bridge
      const bridge = result.length ? result[0] : {}
      if (!bridge.id) {
        log.error('No bridges found!');
        return rej('No bridges found');
      }

      log.info('Found bridge: %s (IP: %s)', bridge.id, bridge.ipaddress)
      res(bridge)
    })
  })
github mpj / workroom-lights-killer / src / play.js View on Github external
api.lights()
    .then(displayResult)
    .done();
/*

// Using a promise
api.registerUser(hostname, null, 'dshjdksaskhjd')
    .then(displayUserResult)
    .fail(displayError)
    .done();


// --------------------------
// Using a promise
*/
hue.nupnpSearch().then(displayBridges).done();
api.config().then(displayResult).done();


api.config(function(err, config) {

})
github cheshire137 / hue-steamer / src / server.js View on Github external
server.get('/bridges/discover', async (req, res) => {
  const timeout = 2000; // 2 seconds
  hue.nupnpSearch(timeout).then((bridges) => {
    res.json(bridges);
  }).fail((err) => {
    res.status(400).json(err);
  }).done();
});
github sinedied / dmx-hue / lib / hue.js View on Github external
listBridges(print) {
    return hue
      .nupnpSearch()
      .then(bridges => {
        if (print) {
          bridges.forEach(b => console.log(b.ipaddress));
        }
        return bridges;
      }, () => Util.exit('No bridge found'));
  }
github sinedied / dmx-hue / lib / hue.js View on Github external
setupBridge(ip = null, force = false) {
    const bridge = Util.config.get('bridge');
    if (bridge && Util.config.get('user') && !force) {
      console.log(`Bridge configured at ${bridge}`);
      return Promise.resolve();
    }
    return hue
      .nupnpSearch()
      .then(bridges => {
        const bridge = ip ? bridges.find(b => b.ipaddress === ip) : bridges[0];
        if (bridge !== null) {
          Util.config.set('bridge', bridge.ipaddress);
          console.log(`Hue bridge found at ${bridge.ipaddress}`);
          return this.bridge;
        }
        return Promise.reject();
      })
      .catch(() => {
        if (ip) {
          Util.config.set('bridge', ip);
          console.log(`Forced Hue bridge at ${ip}`);
          return this.bridge;
        }
github jaredpalmer / hyperhue / init.js View on Github external
const init = () => {
  Hue.nupnpSearch().then(bridges => {
    if (bridges.length > 0 ) {
      if (bridges.length  == 1) {
        return bridges[0].ipaddress
      } else {
        console.log('\n')
        console.log(chalk.cyan(`${bridges.length} Hue Bridge(s) Found:\n`))
        bridges.map((b,i) => console.log(chalk.yellow(`${i+1}: ${b.name || ''}  ${b.ipaddress}  \n`)))
        prompt.start()
        return prompt.get(schema, (err, result) => {
          return bridges[result.bridgeNumber - 1].ipaddress
        })
      }
    }
  }).then(host => {
    const hue = new Hue.HueApi()
    return createUser(host)
github physiii / open-automation / controllers / gateway.js View on Github external
function find_hue_bridge() {
  var hue = require("node-hue-api");
  hue.nupnpSearch(function(err, result) {
	console.log("find_hue_bridge",result);
    if (err) throw err;
    found_bridge = false;  
    for (var i = 0; i < device_array.length; i++) {
      if (device_array[i].id == result[0].id) {
	console.log("bridge already exist, creating user...");
	create_user(result[0]);
	found_bridge = true;
      }
    }
    if (found_bridge == false) {
      console.log("new bridge, creating user...");
      device_array.push(result[0]);
      store_device_object(result[0])
      create_user(result[0]);
    }
github physiii / open-automation / gateway / devices / lights.js View on Github external
function find_hue_bridge() {
  var hue = require("node-hue-api");
  hue.nupnpSearch(function(err, result) {
	console.log("find_hue_bridge",result);
    if (err) throw err;
    found_bridge = false;  
    for (var i = 0; i < device_array.length; i++) {
      if (device_array[i].id == result[0].id) {
	console.log("bridge already exist, creating user...");
	create_user(result[0]);
	found_bridge = true;
      }
    }
    if (found_bridge == false) {
      console.log("new bridge, creating user...");
      device_array.push(result[0]);
      database.store_device(result[0])
      create_user(result[0]);
    }