Skip to content

Commit

Permalink
update to new hue-js interface, storing username token in config file
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbucci committed Sep 15, 2016
1 parent a9b31b3 commit 0026cfa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions hue-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,20 @@ switch (args[0]) {
case 'register': // register this app
client = getclient();
console.log('please go and press the link button on your base station');
client.register(function(err) {
client.register(function(err, resp) {
if (err) {
console.error('failed to pair to Hue Base Station %s', config.host);
throw err;
}

console.log('Hue Base Station paired!')
console.log('username: ' + resp[0].success.username);
config.username = resp[0].success.username;

// writing config file
var s = JSON.stringify(config, null, 2);
fs.writeFileSync(configfile, s + '\n');
console.log('config file written to `%s`', configfile);
});
break;
case 'search': // search for base stations
Expand Down Expand Up @@ -290,7 +298,8 @@ function getclient() {
// create the client
var client = Hue.createClient({
stationIp: config.host,
appName: app
appName: app,
username: config.username
});
return client;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dependencies": {
"posix-getopt": "~1.0.0",
"hue.js": "https://github.com/bahamas10/hue.js/tarball/dave-1432672068",
"hue.js": "https://github.com/bahamas10/hue.js/tarball/master",
"latest": "~0.1.1",
"css-color-names": "0.0.0",
"extsprintf": "~1.0.2"
Expand Down

0 comments on commit 0026cfa

Please sign in to comment.