-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetSetupInfo.js
More file actions
25 lines (24 loc) · 1.24 KB
/
Copy pathgetSetupInfo.js
File metadata and controls
25 lines (24 loc) · 1.24 KB
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
let snek = require('snekfetch');
console.log(`Searching for Hue Bridge...`);
snek.get("https://discovery.meethue.com").then(res1 => {
if (res1.body[0] != null) {
console.log(`Bridge found @ ${res1.body[0].internalipaddress}! Creating New User...`);
snek.post(`http://${res1.body[0].internalipaddress}/api`).send(`{"devicetype":"iderp#nodeutils"}`).then(res2 => {
if (res2.body[0] != null) {
if (res2.body[0].success != null) {
console.log(`Success! Please copy the following into the config file:\n\nloginKey: ${res2.body[0].success.username}\nbridgeIP: ${res1.body[0].internalipaddress}`)
} else {
console.log(`An error has occured!`)
console.log(`Error ${res2.body[0].error.type} | ${res2.body[0].error.description} | ${res2.body[0].error.address}`)
}
} else {
console.log(`An unknown error occured!`)
}
}).catch(err => {
console.log(`An error has occured!`)
console.log(err)
})
} else {
console.log("No bridges found! Please make sure the bridge is turned on and connected to the correct network.")
}
})