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?

gerwitz
  • 1,096
  • 10
  • 13

2 Answers2

3

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

Maarten
  • 635
  • 2
  • 8
  • 22
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

  • 5
    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). – gerwitz Oct 21 '14 at 16:48
  • I don't think that's possible with the current Hue API. I haven't seen recipes in IFTTT for this either. – Koen van der Linden Oct 23 '14 at 06:29