peter-murray / node-hue-api

Node.js Library for interacting with the Philips Hue Bridge and Lights
Apache License 2.0
1.19k stars 145 forks source link

registerUser() triggers ApiError "link button not pressed" immediately #58

Closed cascornelissen closed 8 years ago

cascornelissen commented 8 years ago

The following code triggers the .fail() callback immediately:

var hue = require("node-hue-api");
var api = new hue.HueApi();

// ip = '192.168.2.1'
api.registerUser(ip, null, null).then(function(result) {
    d.resolve();
    console.log('registerUser result:', result);
}).fail(function(result) {
    d.reject('button not pressed');
    console.error('registerUser error:', result);
}).done();

Which results in an immediate ApiError {message: "link button not pressed", type: 101} in my console. I'm still working on the same project as described in #51, so maybe gulp-browserify is messing something up again?

Any ideas on how to solve this?

cascornelissen commented 8 years ago

Nevermind, I misunderstood the documentation. You have to press the button on the hub first and then you have 30 seconds to execute this function.