peter-murray / node-hue-api

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

Purpose of `enableStreaming` method #163

Closed foxriver76 closed 4 years ago

foxriver76 commented 4 years ago

Hey, whats actually the purpose of enableStreaming method. disableStreaming stops syncing the lights with the Hue Sync Box, but enableStreaming just produces an error Unauthorized User at https://github.com/peter-murray/node-hue-api/blob/57619b670bc99f95a4ed82c48501b98d248cd77d/lib/api/http/Transport.js#L69

It seems like enabling the stream is not supported by the original hue api and needs an additional api. See https://github.com/ebaauw/homebridge-hue/issues/552 any plans to support Hue Sync Box in this library?

peter-murray commented 4 years ago

When I originally added this it was around evaluating adding streaming support for entertainment zones.

You can only enable streaming on an entertainment zone, not any other kind of group. Once enabled, there is 20 seconds to start up the streaming negotiation over mtlds, or something like that from memory. It is a udp protocol for sending data to the zone to set colours on the lights.

The streaming API requires this low level udp library support and when I looked over it, the existing node us libraries in that space were weak or would require work to make them function properly with hue. It also would require binary modules, which massively impacts a library like this, which is sometimes used in the browser, and would require c compilers to install properly.

Other than the enable and disable functions, which are part of the REST api, no other features around streaming will end up in this library.

Once the hue hdmi sync box was added, I stopped looking to support streaming via node.js, as it is a real niche use case and has a hardware solution for it. Also there a numerous considerations around things like people with epilepsy that I really don’t want to get involved in if someone abuses your software.

If there was a large push from the community for something around this, maybe work could be done on streaming, but I think there are better languages for implementing that feature.

peter-murray commented 4 years ago

Not sure why the ticket was closed...

By the way, the unauthorised user is possibly coming from a user account that was not created with the client key when it was created. Try using a new user with that flag turned on. If not, let me know the full details of the error and I can look into it.

peter-murray commented 4 years ago

Incidentally, the bridge can only support one active stream at a time

foxriver76 commented 4 years ago

Thanks for sharing your thoughts on this. I totally agree with you on this. Also, it seems like recreation of the credentials worked for the user. Furthermore, enableStreaming seems to do something on the API, because Hue Sync Box App and Philips Hue App both show a message that someone else is currently streaming and after 5 seconds the message disappears again and the Entertainment group shows streaming as false again everywhere. But as you said there is probably some action from the streaming device required too.

peter-murray commented 4 years ago

Once the streaming is enabled, you have 10 seconds to establish a connection, including handshaking over an dtls connection with the bridge, which uses the client key.

Streaming, if a dtls connection is established and handshaking is successful, will remain open until nothing is received for 10 seconds, or disable rest endpoint is called.

Roaders commented 3 years ago

so just for my understanding, is it possible to enable and disable the streaming to the sync box using this library? I was thinking that I would have to implement this myself. If it's already done here great!

peter-murray commented 3 years ago

This library has the enable/disable part of the API exposed only, which is done over REST. Once that is active there is a second API the streaming API that uses dtls. Due to some users using this library in the web browser and the depth of messy stuff you have to get into to use the dtls stuff in Node.js nothing more has been done to extend support for that aspect.

Considering the issues of flashing lights, updates and concerns about health and safety I am extremely wary of doing anything in that area based on all the warnings that Signify have in the documentation.