-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.js
40 lines (31 loc) · 945 Bytes
/
configure.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var hue = require("node-hue-api");
var _ = require("lodash");
var Q = require("q");
var displayBridges = function(bridges) {
};
hue.nupnpSearch().then(displayBridges).done();
var HueApi = require("node-hue-api").HueApi;
var hostname = null;
var newUserName = null;
var userDescription = "reportr hue alerts";
hue.nupnpSearch()
.then(function(bridges) {
var bridge = _.first(bridges);
if (!bridge) throw "No bridge found";
hostname = bridge.ipaddress;
console.log("Hue Bridges Found: " + hostname);
console.log("Press the button in your bridge in the next 10seconds");
return Q.delay(10000);
})
.then(function() {
console.log("Registrating user...");
var api = new HueApi();
return api.registerUser(hostname, newUserName, userDescription);
})
.then(function(result) {
console.log("Created user: " + JSON.stringify(result));
})
.fail(function(err) {
console.log(err);
})
.done();