jdomeij / node-red-contrib-node-hue

Node RED nodes for controlling Philips Hue lights
Apache License 2.0
17 stars 8 forks source link

When adding more than 16 lamps to bridge, new lamps show disconnected #17

Open Eggn1n3 opened 6 years ago

Eggn1n3 commented 6 years ago

Hi, When I add more than 16 lamps to the bridge it seems the new lamps show disconnect in node-red although they still work in node-red. When I add a 2nd node as bridge, new lamps (17+) show connected. I use bridge v1. Node-red 0.18.1, Node v8.9.4 on a raspberry-Pi3 Thanks,

Eggn1n3 commented 6 years ago

Update: I can add the 17th lamp to the hue node, but some other lamps I add still show "disconnected".

jdomeij commented 6 years ago

The only thing that I can think of is that the hub has an limitation of number of lights that can be returned in an single REST API query,

RaymondMouthaan commented 6 years ago

Since yesterday, I moved from "the other" hue node implementation to this implementation of node-red hue, because of it's stability. I've added 23 bulbs (9 Philips hue + 14 Ikea Tradri) and 7 groups. All lights and groups have an hue-in node and a hue-out node. All hue-in nodes are using a bridge called "Hue Bridge 1", while all hue-out nodes use bridge named "Hue Bridge 2". Each bridge has it's own user created on the Philips hub.

A separate bridge/user for hue-in nodes and hue-out nodes, helped me preventing the "disconnect" status.

background: before above solution I had a bridge/user defined for each group and for as well the hue-in as hue-out node I used associated bridge/user. So I had 7 bridges defined. This gave for some hue-in nodes a disconnect status, however the node did respond normally. The above solution reduces the number of bridges (from 7 to 2) and prevents the disconnect status.

Maybe the hub just doesn't like a user send and receive at the "same time" ... ?

Anyway, hope this helps others to prevent the disconnect status.

Last but not least, I like to thank @jdomeij for create this awesome stable implementation of hue for node-red, keep up the good work 👍

K-RAD commented 6 years ago

So you're using 2 physically different bridges to control the same lights?

RaymondMouthaan commented 6 years ago

So you're using 2 physically different bridges to control the same lights?

No i don't, I have just 1 physical Philips Hue Bridge, but two node-hue-bridges, one for all hue-in nodes and one for all hue-out nodes. This means the hue-in nodes use a different account then the hue-out nodes, this helped me to get rid of the disconnect statuses.

jdomeij commented 6 years ago

I recommend to only use one bridge node for each Philips Hue Bridge, defining multiple bridge nodes will increase the load for the bridge. The bridge node will request the status for all lights in one request (and another for all groups) during update and defining multiple bridge nodes will request the data multiple times.

RaymondMouthaan commented 6 years ago

@jdomeij, yes i understand, but with only 1 node-bridge disconnect status shows up ...

jdomeij commented 6 years ago

Hmmm not certain how that can happen, I don't understand how it can work with multiple node-bridges but not one. But if two node-bridges works for you then it's good

RaymondMouthaan commented 6 years ago

I just set all nodes back to use only one node-bridge and removed the second, disconnect reappears for one hue-in node, but it works normally. Is it maybe for some reason the wrong status ? I mean if it is really disconnected then it would not work correctly right?

jdomeij commented 6 years ago

Create an folder on disk and run npm install node-hue-api inside it

Paste the code below inside test.js and replace <ip> and <api key> with the correct values, this will print the state of all the lights on the hub to the console. This is the data that the bridge node is using to determine the state of the lights of

var HueApi = require("node-hue-api").HueApi;

var host = "<ip>",
    username = "<api key>",
    api;

api = new HueApi(host, username);

api.lights()
  .then(data => {
    data.lights.forEach((light)=>{
      console.log(`${light.id}:  ${light.state.reachable?"online ":"offline"} "${light.name}"`);
    });
    //console.log(JSON.stringify(data, null, 2));
  })
  .fail(err => {
    throw err;
  })
  .done();
RaymondMouthaan commented 6 years ago

This is what test.js prints, so all lights are online

1:  online  "Scullery Ceiling Light 1"
2:  online  "Bed Room Ceiling Light 1"
3:  online  "Living Room TV Cabinet Light 1"
4:  online  "Bed Room Ceiling Light 2"
5:  online  "Bed Room Ceiling Light 3"
6:  online  "Bed Room Bed Light 1"
7:  online  "Living Room Window Light 1"
8:  online  "Dining Room Ceiling Light 1"
9:  online  "Dining Room Ceiling Light 2"
10:  online  "Living Room Palm Tree Light 1"
11:  online  "Office Ceiling Light 1"
12:  online  "Office Ceiling Light 3"
13:  online  "Office Ceiling Light 2"
14:  online  "Office Ceiling Light 4"
15:  online  "Hallway Ceiling Light 1"
16:  online  "Hallway Ceiling Light 2"
17:  online  "Hallway Ceiling Light 3"
18:  online  "Hallway Ceiling Light 4"
19:  online  "Kitchen Ceiling Light 1"
20:  online  "Kitchen Ceiling Light 3"
21:  online  "Kitchen Ceiling Light 2"
22:  online  "Kitchen Ceiling Light 4"
23:  online  "Scullery Ceiling Light 2"

But as you can see below, one hue-in node configured for a group shows disconnected. It's there a way to check its status like test.js ?

All of these are groups screen shot 2018-08-08 at 21 40 55

RaymondMouthaan commented 6 years ago

After a while more Hue-in nodes became "disconnected", groups as well as lights related. While this happend I ran the test.js script again, which displayed the same results as above (all lights online).

As for now I switched back to the second hue-bridge solution and so far this works perfectly.

If there is anything I can do to solve this issue, just let me know!

K-RAD commented 6 years ago

I just move to this from HueMagic where I used to get loads of connection errors, and no issues so far with only one hub config for 13 hue bulbs. Maybe your poll interval is set too low?

RaymondMouthaan commented 6 years ago

I just move to this from HueMagic where I used to get loads of connection errors, and no issues so far with only one hub config for 13 hue bulbs. Maybe your poll interval is set too low?

I've been using HueMagic before and I switch to node-red-contrib-node-hue, because it is much more stable. With HueMagic I faced many connection errors (debug window), at least every time I deployed node-red flows. Since I am not using any non-light, devices the switch was easily decided.

My poll time is set to 3s, but i've tried 1s and 10s as well, both did not make any difference.