mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
22 lines
649 B
TypeScript
22 lines
649 B
TypeScript
/// <reference path="index.d.ts" />
|
|
|
|
import hue = require('node-hue-api');
|
|
|
|
hue.nupnpSearch().then(function (bridges) {
|
|
if (!bridges || !bridges[0]) {
|
|
throw "No bridge found";
|
|
}
|
|
let ip = bridges[0].ipaddress;
|
|
//First load username from file. Register if there's no file.
|
|
let api = new hue.HueApi();
|
|
api.registerUser(ip).then(newUser => {
|
|
console.log("Created Hue user: " + JSON.stringify(newUser));
|
|
}).then(listScenes.bind(this, api));
|
|
})
|
|
|
|
|
|
function listScenes(api: hue.HueApi) {
|
|
return api.getScenes().then(function (scenes) {
|
|
return console.log(scenes.map(s => s.name).join(", "));
|
|
});
|
|
} |