我想回应ZGP(Tap)开关的事件。根据我在API文档中阅读的内容,我必须通过常规方式查看传感器并在状态描述中查找buttonevent
进行轮询。
当然,还有更好的方法。有没有人找到一种方法将回调添加到Hue桥或任何其他技术以避免持续轮询?
答案 0 :(得分:1)
我正在检查JSON。您首先拥有场景(4,TAP上每个按钮一个),如:
"OFF-TAP-1": {
"name": "Tap scene 1",
"lights": [
"1",
"2",
"3"
],
"active": true
},
然后你有规则说明发生事件时发生的事情(按下TAP按钮)
"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"
}
}
]
},
因此无需轮询TAP的状态。如果按下按钮。将触发相应的规则,然后启动定义的操作。在这种情况下,它将启动场景" OFF-TAP-1"。
更多文档:http://www.developers.meethue.com/hue-tap-scene-programming