How to use the node-hue-api.HueApi 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 netbeast / api / api_hue / lights.js View on Github external
var fs = require('fs')
var	async = require('async')
var	hue = require('node-hue-api')
var	HueApi = require('node-hue-api').HueApi
var	hueapi = new HueApi()

var ipbridge
var api

module.exports = function (callback) {
  async.waterfall([
    hue.nupnpSearch,
    function (result, callback) {
      ipbridge = JSON.stringify(result[0].ipaddress)
      ipbridge = ipbridge.split('"')[1]
      console.log('Hue Bridges Found: ' + ipbridge)
      callback.call(this, null)
    },

    function createUser (callback) {
      fs.readFile('username.txt', function (err, user) {
github physiii / open-automation / gateway / devices / lights.js View on Github external
function find_lights(device) {
  hue = new HueApi(device.ipaddress,device.user);
  hue.lights(function(err, lights) {
    if (err) console.log(err);
    for (var i = 0; i < device_array.length; i++) {
      if (device_array[i].id == device.id) { 
        if (!lights) return console.log("find_lights | ",lights); 
	device_array[i].lights = lights.lights;
        database.store_device(device_array[i]);
        console.log("storing lights");
      }
   }
  });
}
github physiii / open-automation / controllers / gateway.js View on Github external
function set_light(device_id,state) {
  //console.log("set_light",state);
  for (var i = 0; i < device_array.length; i++) {
    if (device_array[i].device_type == "lights") {
  
      hue = new HueApi(device_array[i].ipaddress,device_array[i].user);
      hue.setLightState(device_id, state, function(err, results) {
        if (err) console.log(err);
      });
      //find_lights(device_array[i]);
    }
  }
}
github ecaron / smart-nightlight-manager / setup.js View on Github external
var displayBridges = function (bridge) {
  if (bridge.length === 0) {
    console.warn('No bridges found. Do you need to set/create the TIMEOUT environment variable?');
    return;
  }
  console.log('Hue Bridges Found: ' + JSON.stringify(bridge));
  var hue = new HueApi.HueApi();
  var newUser = false;

  async.whilst(
    function () { return newUser === false; },
    function (callback) {
      hue.createUser(bridge[0].ipaddress, function (err, user) {
        if (err) {
          if (err.message === 'link button not pressed') {
            console.log('Bridge button has not been pressed. Pausing 5 seconds while you press it...');
            setTimeout(callback, 5 * 1000);
          } else {
            return callback(err);
          }
        } else {
          newUser = user;
          return callback();
github physiii / open-automation / gateway / devices / lights.js View on Github external
function set_light(device_id,state) {
  console.log("set_light",state);
  for (var i = 0; i < device_array.length; i++) {
    if (device_array[i].device_type == "lights") {
      hue = new HueApi(device_array[i].ipaddress,device_array[i].user);
      hue.setLightState(device_id, state, function(err, results) {
        if (err) console.log(err);
      });
      find_lights(device_array[i]);
    }
  }
}
github physiii / open-automation / gateway / devices / lights.js View on Github external
function set_theme(theme) {
  if (alert == true) {
    setTimeout(function () {
      set_theme('alert');
    }, 2*1000);
    if (state == red) {
      state = blue;
    } else 
    if (state == blue) {
      state = red;
    }
    else state = red;
  }
  for (var i = 0; i < device_array.length; i++) {
    if (device_array[i].device_type == "lights") {
      hue = new HueApi(device_array[i].ipaddress,device_array[i].user);
      for (var j = 0; j < device_array[i].lights.length; j++) {
        if (theme == 'presence') {
          if (device_array[i].lights[j].on) continue;
          state = presence;
        }
        set_light(device_array[i].lights[j].id,state);
      }
    }
  }
}
github sogehige / sogeBot / src / bot / integrations / phillipsHue.js View on Github external
onStateChange (key: string, value: string) {
    if (value) {
      if (this.settings.connection.host.length === 0 || this.settings.connection.users.length === 0) return

      this.api = new HueApi(
        this.settings.connection.host,
        this.settings.connection.user,
        this.settings.connection.timeout,
        this.settings.connection.port)

      this.states = []
      global.log.info(chalk.yellow('PHILLIPSHUE: ') + 'Connected to api')
    } else {
      this.api = null
      global.log.info(chalk.yellow('PHILLIPSHUE: ') + 'Not connected to api')
    }
  }
github kvartborg / hueify / src / views / Connect / Connect.jsx View on Github external
connect () {
    const hue = new HueApi()
    hue.registerUser(this.props.settings.host, 'Hueify')
      .then(this.success.bind(this))
      .fail(() => {})
      .done()
  }