How to register a listener for a button capability?

Hello, I try to write a driver for a virtual push button device (push only, not on-off) based on the button device class with a button capability. I have problems finding out how add an event handler to be fired when the user press the button in the Homey app.

I have tried to use registerCapabilityListener(‘button’) but no event is fired when I press the button in the Homey App. I also notice that the Homey app tells me that the device is not controllable.

I have also looked into adding an action listener using registerRunListener, but I do not find any way to related the action the a specific device.

Any suggestions?

Works fine for me.

This is what it looks like in the web app:

Ok, I have registered this for class and capability in the driver.compose.json:

“class”: “button”,
“capabilities”: [
“button”
],

Anything else needed?

Are you using registerCapabilityListener(‘button’) to handle the push event?

-Trygve

I guess you didn’t spot the link I posted: https://github.com/robertklep/name.klep.homekitty/blob/87880f54abb9f754d531d990c71952e5211c83ab/drivers/flow-starter/driver.compose.json

The only difference seems to be that I’m using other as device class, not button.

Thanks a lot - device class “other” did the trick!

-Trygve

1 Like

BTW, is it possible to listen to action cards for devices? Did not find a way to associate the action flow card with a device when getting the action.

-tr

The device is available as args.device (where args is the first argument that gets passed to the run listener).

Ok, thanks a lot! That information seems to be missing in the SDK documentation for RunCallback.

-tr

You’ll probably find that a lot of intricacies aren’t (properly) documented :woozy_face: