peter-murray / node-hue-api

Node.js Library for interacting with the Philips Hue Bridge and Lights
Apache License 2.0
1.19k stars 145 forks source link

Example returns same bridge twice #114

Closed njlr closed 5 years ago

njlr commented 6 years ago

Not a major issue from an API-consumer perspective, but it might indicate an error internally.

When I run this:

var hue = require("node-hue-api"),
    timeout = 2000; // 2 seconds

var displayBridges = function(bridge) {
    console.log("Hue Bridges Found: " + JSON.stringify(bridge));
};

hue.upnpSearch(timeout).then(displayBridges).done();

I get this output:

Hue Bridges Found: [{"id":"001789ffde3890ac","ipaddress":"172.16.0.64"}]
Hue Bridges Found: [{"id":"001789ffde3890ac","ipaddress":"172.16.0.64"}]

Note how the callback is hit twice.

My yarn.lock:

...
node-hue-api@^2.4.2:
  version "2.4.2"
  resolved "https://registry.yarnpkg.com/node-hue-api/-/node-hue-api-2.4.2.tgz#f721aba415a6c4a8d0b4c2af0ab36939f0ab5cb7"
  dependencies:
    axios "~0.15.3"
    deep-extend "~0.4.0"
    q "~1.4"
    traits "~0.4.0"
    xml2js "~0.4"
...

I am on macOS.

$ node --version 
v9.3.0
peter-murray commented 6 years ago

Thanks for filing the issue with enough details so I could attempt to recreate.

I cannot get the library to reproduce your results. I am also on macOS, and tested under Node.js 8, 9.4.0 and 9.3.0....

The only difference is that I don't use yarn, but the dependencies are the latest resolved from the npm registry.

njlr commented 6 years ago

I see... then I suggest we leave this if/until someone else encounters the issue.

cKhoff commented 6 years ago

i have the same issue running on mac on node 8.9.4 LTS

peter-murray commented 6 years ago

I need more details, as to your setups as I cannot reproduce.

What is your bridge set up as, I have a static up address for mine as well as running pfsense as my firewall, dns and dhcp server.

I also do not use yarn, are you both using that to resolve dependencies? Clearly there is something significantly different that I don’t have and until it can reproduce there is little I can do to resolve it. Can you try a different version of node at your spend, like node 6 and see if it still happens, at least then things may become clearer as to a source of the issue.

I really need to finish off pulling out the Q promise library now that they are well established inside the JavaScript world, but nothing has change with discovery for a long time now, so I suspect it is either something in the network or dependencies.

cKhoff commented 6 years ago

Hi there, thank u for ur fast response 👍 My setup should be similar tu urs, i guess and the brigde has a static ip and running in my local subnet.

environment setup:

OS

Darwin Christians-MacBook.fritz.box 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 `x86_64

Node

v9.4.0|v8.9.4

Solved 4 me

But finally the fault was behind the machine.... I figured out that u offer the Promise # AND the functional way 🥇 in addiction to @njlr i just c&p the example and was to greedy....

Still got at lot 2 learn :)