Skip to content

Instantly share code, notes, and snippets.

@ReidCarlberg
Created February 20, 2014 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ReidCarlberg/9123500 to your computer and use it in GitHub Desktop.
Save ReidCarlberg/9123500 to your computer and use it in GitHub Desktop.
var HueApi = require("node-hue-api").HueApi;
var hostname = "192.168.1.103",
newUserName = null // You can provide your own username value, but it is normally easier to leave it to the Bridge to create it
userDescription = "device description goes here";
var displayUserResult = function(result) {
console.log("Created user: " + JSON.stringify(result));
};
var displayError = function(err) {
console.log(err);
};
var hue = new HueApi();
// --------------------------
// Using a promise
hue.registerUser(hostname, newUserName, userDescription)
.then(displayUserResult)
.fail(displayError)
.done();
// --------------------------
// Using a callback (with default description and auto generated username)
hue.createUser(hostname, null, null, function(err, user) {
if (err) throw err;
displayUserResult(user);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment