Created
February 20, 2014 21:25
-
-
Save ReidCarlberg/9123500 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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