yadomi / node-red-contrib-philipshue-events

Implements the Philips Hue API v2 EventSource as a node-red node
MIT License
14 stars 2 forks source link

(still) stops receiving of events #15

Open BoBeRzE opened 2 years ago

BoBeRzE commented 2 years ago

Hi,

I'm still having disconnects after a few hours detailed in this link:

https://github.com/yadomi/node-red-contrib-philipshue-events/issues/7

i use v1.4.2 of your package and my node red version is v3.0.2 in a docker container https://hub.docker.com/r/nodered/node-red

i use the nodes from https://github.com/andesse/hue-clip-api.node-red-flows in combination with node-red-contrib-knx-ultimate

Thank you for your help

andesse commented 2 years ago

@BoBeRzE

Hey, do you have any motion Sensor in your setup? The contrib runs for me issue free.

Obviously it could be a problem when your stream is too silent for a long time. i have a couple of sensors, they send temperature and light level frequently.

If you have none, that could cause your problem and consider to buy just one to keep the eventstream alive.

Edit: that’s an idea, I didn’t proof it

Nice that you use my flow :)

BoBeRzE commented 2 years ago

Sorry for the late reply. Yes, I have a motion sensor. However, the connection is lost after a while. I am currently using the sse-client as a receiver for the HUE events. In my tests with short timeouts, the connection was reliably reconnected. I am now testing with a timeout value of 60 minutes and see if that fits. Otherwise I have to fine-tune the values ​​a bit.

@andesse, thanks for your flow. That was a really good starting point for my project. I will continue to pursue it.

andesse commented 2 years ago

Hey, nice that it works out like that.

But really strange. I never had a timeout with Yadomi node. I am running Node Red directly on a Tinkerboard. Maybe running it in a container is a problem? Can you check the network settings for your Docker setup?

BoBeRzE commented 2 years ago

I don't think the network is the cause. I also run some other services (e.g. InfluxDB) in a container. If there were a problem with the network, I would also be missing some sensor data on a regular basis. But no matter if the sse-client works, I'm satisfied ;)

andesse commented 2 years ago

@BoBeRzE I don’t mean the network directly. I have no experience with docker, but could it be possible that the docker host has a timeout/reconnect setting for the NR instance? if so this could effect the Eventstream node.

loupiz commented 2 years ago

Hi,

I have the same issue with the motion sensor and the smart button. They get disconnected after a few hours. Node red also runs in a docker container. @BoBeRzE did you manage to figure something out ?

Thanks

andesse commented 2 years ago

@loupiz Then try to use this https://github.com/andesse/hue-clip-api.node-red-flows/blob/main/flows/SSE_Event_Stream.json

for me yadomi contrib works completely fine

loupiz commented 2 years ago

I had to decrease the timeout but it seems to be working fine so far. Thanks !

yadomi commented 2 years ago

Hello @BoBeRzE, I'm not sure what can cause this issue. I've been using the node for quite some month now and didn't had any disconnect. My Hue setup consist of 3 switchs, 3 motions sensor and a numerous amount of lights. I'm also running Node-RED (v3.0.0) inside a docker container.

This won't be easy to debug.

Does redeploying the Node-RED flow fix (temporarily) the issue or you should restart the whole Node-RED instance ?

The node should emit an error when an error occurs. You can try to catch it with the catch node plugged to a debug node, see: https://nodered.org/docs/user-guide/handling-errors#catchable-errors.

That could give us more info

VisualReversal commented 2 years ago

I just discovered I wasn't the only one this is happening to. This has been going on for a few weeks now and some days it'll happen multiple times a day. I'm running the latest version of everything on a dedicated RPi 400.

As far as I can tell it's only my motion sensors that become non responsive. This is totally random, but when it happens, it affects all of them. A restart of node-red solves it 100% of the time, so now I now have a verbal command via Alexa to restart node-red for me.

Even though I don't have the motion sensors configured in the Hue iOS app, I can check on them there and they are indicating motion when there is motion. Using debug nodes I've at least figured out that the motion events aren't being reported by the events node. So, I'll have to do some more checking to see if it's all events or just motion when it happens.

andesse commented 2 years ago

@VisualReversal sometimes I need to refresh the browser to see debug messages. Do you switch the messages to a true/false? Hue recently made a change how the bridge sends events. Before it was single events, now they combined them to an array when several events occur at the same time. if this is the case you need to split the arrays. You could have a look on that.

It also could help to generate a new api key. Had the issue that the old wasn’t working properly after an Bridge firmware update.

Array splitter: [{"id":"343b7eb78003c833","type":"function","z":"fe62da1.b2b0828","name":"Array Splitter","func":"for (var i = 0; i < msg.payload.data.length; i++) {\n // Create a deep copy of msg object\n let splitmsg = JSON.parse(JSON.stringify(msg));\n\n // Reset data of new message to its single data part\n splitmsg.payload.data = [msg.payload.data[i]];\n \n // send using node\n node.send(splitmsg);\n}\n\nreturn;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3750,"y":360,"wires":[["38c2c82e186a4c1e","479b98d.3792868"]]}]

Greetings Andreas

VisualReversal commented 2 years ago

Interesting. Yeah, I've been searching payload.data.0.motion.motion and using a true/false switch to direct them. I suppose msg.payload.data.0.id isn't going to always work with that being the case. Good to know. I'll get to work on trying out the array splitter. Thanks for that!

andesse commented 2 years ago

Interesting. Yeah, I've been searching payload.data.0.motion.motion and using a true/false switch to direct them. I suppose msg.payload.data.0.id isn't going to always work with that being the case. Good to know.

I'll get to work on trying out the array splitter. Thanks for that!

The splitter comes behind the hue event node from yadomi, forgot to mention. Let me know if that was the problem

VisualReversal commented 2 years ago

@andesse - After extensive testing I can confidently say that your array splitter has totally fixed the issue. A million thanks!!

andesse commented 2 years ago

@andesse - After extensive testing I can confidently say that your array splitter has totally fixed the issue. A million thanks!!

@VisualReversal Welcome my friend! Great that it works. Let the light be shine on you ;)

jcislinsky commented 2 years ago

Hi, I have exactly the same problem. How can I debug what is happening inside the philipshue-events node? The node shows "Listening" but no event is received. I have lights and many motion sensors.

Redeploy does the trick, but it's not a solution.

Thanks for your assistance.

andesse commented 2 years ago

Hi,

I have exactly the same problem. How can I debug what is happening inside the philipshue-events node? The node shows "Listening" but no event is received. I have lights and many motion sensors.

Redeploy does the trick, but it's not a solution.

Thanks for your assistance.

@jcislinsky get a new api token, that should help if you got recently a bridge update. Api V2 is still beta (or early access) and HUE changes quite a bit.

svenerbe commented 1 year ago

Hi, i have since 2 weeks the same issue, i have nothing changed but event listener is showing listening but there is no events receiving. after redeployment is working again for some hours. i have as well collect a new api key, but is not fixing the issue. i'm using as well array splitter.

Thanks

andesse commented 1 year ago

Hi, i have since 2 weeks the same issue, i have nothing changed but event listener is showing listening but there is no events receiving. after redeployment is working again for some hours. i have as well collect a new api key, but is not fixing the issue. i'm using as well array splitter.

Thanks @svenerbe

use the SSE Event stream from my repository, this works flawless. https://github.com/andesse/HUE-CLIP-API.Node-RED-Flows/blob/main/flows/SSE_Event_Stream.json

Description is in my Repository as well

Greetings Andreas

svenerbe commented 1 year ago

Hi, i have try to import the flow but i get the question some of the nodes are already in the workspace. than i have just press import copy. need i something else to configure? currently after import to old flows are not working - sorry for the question.

andesse commented 1 year ago

Hi, i have try to import the flow but i get the question some of the nodes are already in the workspace. than i have just press import copy. need i something else to configure? currently after import to old flows are not working - sorry for the question.

@svenerbe you can import a copy. You can either delete them before deploy or also afterwards. It may be subflows you just get duplicates. Don't worry.

svenerbe commented 1 year ago

@andesse , i have done this, after import and configure of the flow - no action like lamp on/off is anymore working - after deletion of the flow - all is working fine again:-) any tips?

andesse commented 1 year ago

I don't understand the Question/ Problem.

Erkläre es auf deutsch wenn Du möchtest;)

svenerbe commented 1 year ago

@andesse - step by step

  1. neuen Flow erstellt - damit schalte ich einfach mal eine Lampe durch inject image

  2. dein Flow in meinen test flow importiert und konfiguriert: image

  3. danach nochmal versucht die lampe zu schalten: image

danach kommt nur im debug - "JSON-Parse-Fehler"

svenerbe commented 1 year ago

@andesse , maybe found the issue - there was some philipshue-events nodes with different philipshue-events-config (different api key) on different flows. after fixing its working. i will see if this will help to fix the problem with stop receiving of events. many thanks for your help.

andesse commented 1 year ago

@svenerbe great that it works! If you want to keep the eventflow 24/7/365 alive, buy one motion sensor and it will never run dry on data and disconnects :)