I’ve tried to set up a handler to be called when a two-button device is pressed, both with using the rest API with json payloads, and using the SmartApp JS SDK. There are no errors reported and a call to the /subscriptions API confirms that a subscription has been set up, but I never get any events.
Does anyone know if there is a working example of a SmartApp successfully subscribing to a button?
Tech support has not pointed out anything I’m doing wrong according to the documentation.
But curiously, they won’t confirm to me that they know it does work for a fact.
Even more curiously, they say they cannot replicate my problem using the information I have provided them so far. Since my problem is that I am seeing no events being triggered, then by implication, it means that tech support are able to see events being triggered, so it strikes me as curious that they won’t confirm what they are seeing and show me what the payload looks like. Instead they keep asking me for more and more information so that they can replicate a scenario in which nothing happens…
So I wondered, if anyone out there knows of an instance where a button being pressed generated a call to an event handler.
Following is the /subscriptions output, which shows I have a motion sensor (which gives me events) and a button sensor (which does not) subscribed:
{
"items": [
{
"id": "<...>",
"installedAppId": "<installed app id>",
"sourceType": "DEVICE",
"device": {
"deviceId": "<button id>",
"componentId": "button2",
"capability": "button",
"attribute": "button",
"value": "*",
"stateChangeOnly": true,
"subscriptionName": "myButtonEventHandler_0",
"modes": [
]
}
},
{
"id": "<...>",
"installedAppId": "<installed app id>",
"sourceType": "DEVICE",
"device": {
"deviceId": "<motion detector id>",
"componentId": "main",
"capability": "motionSensor",
"attribute": "motion",
"value": "*",
"stateChangeOnly": true,
"subscriptionName": "myMotionEventHandler_0",
"modes": [
]
}
}
],
"_links": {
}
}
(BTW, the reason I wanted to see the payload in the case where tech support said they were not able to replicate the non-occurrence of an event, was that I am wondering about the available states documented for a button are like pressed, held, down (i.e. button2), up (i.e. button1), etc, but not released. On the other hand the motion sensor and the contact sensor have available states like active/inactive and open/closed. i.e. states that you could transition between. The button is a momentary action button, so whenever you query the state by polling it’s always pushed. So how does an event get reported, I wondered.)