Does anyone know about `button` capability's `numberOfButtons` Attributes?

From capabilities reference, we can find 3 attributes on button capability.
which:

  1. button
  2. numberOfButtons
  3. supportedButtonValues

These attributes are clear and intuitive, but numberOfButtons doesn’t make any change on new-app.

What is that?

Number of Buttons indicates how many different buttons a device has. Then you can assign a different action to each button, using, for example, the official smart lighting feature.

Is that what you were asking?

3 buttons

4 buttons

That’s exactly what I want to do.
But that didn’t work for me so instead I separate components for each button.
Thanks you for about your answer, I’ll try it more.

1 Like

I’m not sure what “didn’t work”. The numberOfButtons is simply the number of buttons the device has.

Using components is exactly what you need to do with the new app and is generally the way to go.

Older classic apps such as Smart Lighting and webCoRE recognised a buttonNumber carried in the event data. This was used to support multiple clicks as much as multiple buttons as back then the button capability only had pressed and held values.

2 Likes

If you need examples:

  • Search for “x.com.st.d.remotecontroller” under ST github.
  • I have virtual buttons under my github.
2 Likes

Well, sorry I’m little bit confused.

Back to the basic, button capability has 3 attributes, and we use numberOfButtons to report how many button does a device have.

But how can I notify to ST about which button pressed?
I couldn’t find attribute which I can set index of button.

Due to I’m working with Schema Connector, I’m not comfortable with groovy DTH. However I could find a hint from your example.

Thank you very much!

Hi, @zldxkdlrj_dlcmaldml

Since your device will communicate first with your application/Cloud, you can configure your Schema Connector instance to update these states at the SmartThings app using Device State Callbacks. You must use the component Id to specify which of the buttons has been pressed, e.g.:

...
"deviceState": [
    {
        "externalDeviceId": "<deviceId>",
        "states": [
            {
                "component": "button1",
                "capability": "st.button",
                "attribute": "button",
                "value": "held"
            }
        ]
    }
]

Note: For a better reference of OAuth Tokens used in Callback Interaction Types, check the Reciprocal Access Token documentation.

If you feel that this information has cleared your doubts, please mark it as a Solution. However, if you have any other questions, please let me know.

1 Like