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

Is it possible to detect events with the hue tap switch? #179

Closed bicubic closed 4 years ago

bicubic commented 4 years ago

Sorry for posting a question rather than an issue but the resource links seem pretty dead.

Is it possible to intercept tap button events with this library in any way?

Or is it possible to achieve it with other hardware (esp+zigbee?)

peter-murray commented 4 years ago

Its fine, just waiting on access to GitHub Discussions beta so that you can raise questions like this in the future, so issue tickets are fine until then.

The way that the buttons etc... all talk to the bridge is over Zigbee, so there is nothing that can be seen around these types of events until the bridge interprets them and the responds. The bridge does not have anything that you easily poll in this regard to respond in a timely fashion like MQTT that a lot of other solutions tend to use (like esp hardware solutions).

That said there is some ability for integration here that might be useful in the case of CLIP Sensors. CLIP sensors allow you to defined software based sensors that can register state that can be used to drive automation within the bridge itself. This is the underpinnings of the Hue Labs light recipes (or whatever they call them now). Resource Links are actually the bundling of a number of interconnected items in the bridge that deliver a single solution which you can see when you install a new light recipe on your bridge.

So coming back to your question, you can possibly set up one or more CLIP Sensors to capture the details you want and update the value of the CLIP sensors off changes in state using one of more Rules, e.g. User presses TAP button 1 and you update a CLIPGenericFlag Status Sensor to true. You can then periodically poll that sensor using the library from your service/application to check for a change and respond.

Now this is not particularly well suited to instant changes, and the Hue bridge does not respond well to a lot of heavy polling over the network, but a lot of home automation integrations poll around 2 to 5 second intervals.

It would be nice if the Hue Bridge did have some way to publish data out over MQTT, or even send payloads to an URL endpoint as part of their rules system, but currently is it all a little too closed in this regard.