Responding to Hue events?
Asked Answered
D

2

7

I'd like to respond to events from a ZGP (Tap) switch. From what I read in the API documentation, I'll have to poll by routinely GETing the sensor and looking for a buttonevent in the state description.

Certainly there's a better way. Has anyone found a way to add callbacks to a Hue bridge or any other technique to avoid constant polling?

Declivitous answered 16/10, 2014 at 12:8 Comment(0)
L
4

There are local events now as part of the v2 Hue API (login required). The events are sent through server-sent events protocol under /eventstream endpoint.

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

Leggy answered 11/8, 2022 at 6:36 Comment(0)
B
1

As i'm checking the JSON. You first have the scene's (4, one for each button on the TAP) like:

    "OFF-TAP-1": {
        "name": "Tap scene 1",
        "lights": [
            "1",
            "2",
            "3"
        ],
        "active": true
    },

Then you have the rules that states what happens when an event (TAP button presssed) occurs

 "1": {
        "name": "Tap 2.1 Default",
        "owner": "abdbsbdbfh123",
        "created": "2014-09-14T18:29:28",
        "lasttriggered": "2014-10-17T06:03:09",
        "timestriggered": 3,
        "status": "enabled",
        "conditions": [
            {
                "address": "/sensors/2/state/buttonevent",
                "operator": "eq",
                "value": "34"
            },
            {
                "address": "/sensors/2/state/lastupdated",
                "operator": "dx"
            }
        ],
        "actions": [
            {
                "address": "/groups/0/action",
                "method": "PUT",
                "body": {
                    "scene": "OFF-TAP-1"
                }
            }
        ]
    },

So there is no need to poll the status of the TAP. If a button is pressed. The corresponding rule will fire which in turn will start the defined action. In this case it will start scene "OFF-TAP-1".

More documentation: http://www.developers.meethue.com/hue-tap-scene-programming

Bivens answered 17/10, 2014 at 8:41 Comment(2)
Thanks, but I want to respond to the tap events myself. I don't want to activate a scene or do other things the bridge can handle alone, but rather want to trigger my own systems (to e.g. send an email).Declivitous
I don't think that's possible with the current Hue API. I haven't seen recipes in IFTTT for this either.Bivens

© 2022 - 2024 — McMap. All rights reserved.