Converting curl "Event Stream" to node-RED

Philips Hue has introduced a new api which includes functionality to receive an event stream ('Server-Sent-Events', or SSE). This obviates the need to poll the Hue bridge for device states.

"Subscribing" to SSE can be done with:

curl --insecure -N -H 'hue-application-key: <appkey>' -H 'Accept: text/event-stream' https://<ipaddress>/eventstream/clip/v2

so long as this connection is left open, events will arrive like this:

id: 1634576695:0
data: [{"creationtime":"2021-10-18T17:04:55Z","data":[{"id":"e706416a-8c92-46ef-8589-3453f3235b13","on":{"on":true},"owner":{"rid":"3f4ac4e9-d67a-4dbd-8a16-5ea7e373f281","rtype":"device"},"type":"light"}],"id":"9de116fc-5fd2-4b74-8414-0f30cb2cbe04","type":"update"}]

How can I implement the equivalent of this curl in node-RED? (I've had a go with http request, but I am not getting any responses. I should say that I have the appkey and server details and have proven all is working using curl.)

@lorccan,

Perhaps node-red-contrib-sse-client could be of any help? Don't know, because I don't use it myself...

Bart

Thanks Bart

Actually, I have just found NRC-philipshue-events which is exactly what I need. I should have searched inside NR first!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.