-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.js
More file actions
30 lines (27 loc) · 773 Bytes
/
setup.js
File metadata and controls
30 lines (27 loc) · 773 Bytes
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
const huejay = require('huejay');
function createUser(ip) {
console.log(`Hue found at: ${ip}`);
const client = new huejay.Client({
host: ip,
port: 80, // Optional
username: 'macbook', // Optional
timeout: 15000, // Optional, timeout in milliseconds (15000 is the default)
});
const user = new client.users.User();
client.users
.create(user)
.then((user) => {
console.log(`New user created - Username: ${user.username}`);
})
.catch((error) => {
if (error instanceof huejay.Error && error.type === 101) {
return console.log('Link button not pressed. Try again...');
}
console.log(error.stack);
});
}
huejay
.discover({
strategy: 'all',
})
.then(bridges => createUser(bridges[0].ip));