Closed mattfelsen closed 7 years ago
The tests are specify to my own bridge, I use them to check for any regressions, they are not for others to run, as they are not portable (they rely on things in my bridge for validation).
I am considering capturing the results using nock (which I do for another node.js project) but have not had the time to port the test framework over.
There are two methods for finding a bridge, one via an older nupnp and the other upnp search.
nupnp
search is the preferred method, as that will use the meethue portal to discover your bridge, whereas the upnp
search that uses UDP to try and find the bridge on the network, which can be problematic but was the preferred way before Phillips added the meethue option via the API.
Hi Peter, thanks for getting back so quickly! Ok, that makes sense about the tests not working. I'm still having trouble with the nupnp search – but not at the API level. I tried both the promise & callback styles from the bridge-finding example:
var hue = require("node-hue-api");
var displayBridges = function(bridge) {
console.log("Hue Bridges Found: " + JSON.stringify(bridge));
};
// --------------------------
// Using a promise
hue.nupnpSearch().then(displayBridges).done();
// --------------------------
// Using a callback
hue.nupnpSearch(function(err, result) {
if (err) throw err;
displayBridges(result);
});
And for either case I'm getting the same parsing error. Maybe something changed in a new firmware version? The listed software version showin the Hue app is 01036659. Here's the error output:
$ node hue.json
module.js:561
throw err;
^
SyntaxError: /Users/matt/Documents/Code/Projects/magicians/magicians-scripts/hue/hue.json: Unexpected token v in JSON at position 0
at Object.parse (native)
at Object.Module._extensions..json (module.js:558:27)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.runMain (module.js:575:10)
at run (bootstrap_node.js:352:7)
at startup (bootstrap_node.js:144:9)
at bootstrap_node.js:467:3
I just released version 2.4.0 of the library, can you try that (I don't think it will change anything, but will put you on the same as me for testing).
Also can you provide me with the output of the config()
function on your bridge (with things like your mac and ip address taken out) and I can look further into it.
Oy, I just realized an embarrassing mistake. I named my file hue.json
instead of hue.js
, so node was trying to parse it as json. I'm able to get this result now after renaming the file to hue.js
:
Hue Bridges Found: [{"id":"xxx","ipaddress":"yyy"},{"id":"zzz","ipaddress":"www"}]
Sorry for the hassle!
Hi! I was excited to try out this module, but I'm having some trouble getting things working. I have the Bridge plugged into my wifi router via ethernet, and I can use the app to control the bulbs, so I think things are set up on that end. Both the promise and callback style of finding a bridge wasn't working, so I tried running the test suite. My full log is below...let me know if you've got any thoughts! Thanks!