# Direct Connect Device Button Capability and Automations

**URL:** <https://community.smartthings.com/t/direct-connect-device-button-capability-and-automations/221373>\
**Category:** Writing Device Types\
**Created:** [February 24, 2021, 12:00am UTC](https://community.smartthings.com/t/direct-connect-device-button-capability-and-automations/221373 "2021-02-24T00:00:41Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bban](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@bban](https://community.smartthings.com/u/bban)\
**Post date:** [February 24, 2021, 12:00am UTC](https://community.smartthings.com/t/direct-connect-device-button-capability-and-automations/221373/1 "2021-02-24T00:00:42Z")

</div>

Hello, @nayelyz @kwanghui

I’m having an issue with the button capability for direct connected devices. I have my button device connected and when I press, double, or hold, I can see in the app the value update the button capability value briefly before going back to standy. I thought that was all that was required and my button was working. When I tried to hook an automation to it I discovered the automation was not being triggered. Eventually I observed that if I double press or hold then single press the button the automation associated to pressed is executed.

This observation makes me think that automations are not being triggered because the button capability values being updated to ‘pushed’ from ‘pushed’ doesn’t change the state in the cloud resulting in the automation not triggering.

My question is if my direct connected device using the button capability is supposed to clear the button capability value after sending ‘pushed’ or ‘double’? The SmartThings defined button capability doesn’t have a ‘standby’ value so it’s unclear me to what I’m supposed to do after sending the updating button value. Is possible there is an issue in the Smartthings cloud?

---

<div class="post-metadata">

**Author:** ![nayelyz](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@nayelyz](https://community.smartthings.com/u/nayelyz)\
**Post date:** [February 24, 2021, 1:54am UTC](https://community.smartthings.com/t/direct-connect-device-button-capability-and-automations/221373/2 "2021-02-24T01:54:15Z")

</div>

Hi, there! I see what you mean, yes, the button value stays as ‘pushed’ unless you change it. Using DTH, there’s a property added to the event to treat it as a state update (`isStateChange: true`) even it isn’t a different value.  
I’m not sure something similar is available in other integrations so, I would suggest you change the value after a small delay.

---

<div class="post-metadata">

**Author:** ![bban](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@bban](https://community.smartthings.com/u/bban)\
**Post date:** [February 24, 2021, 6:39pm UTC](https://community.smartthings.com/t/direct-connect-device-button-capability-and-automations/221373/3 "2021-02-24T18:39:58Z")

</div>

@kwanghui Do you know if there is any plan to add a isStateChange like functionally to the direct connected device API?

---

<div class="post-metadata">

**Author:** ![orangebucket](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/orangebucket/32/81590_2.png) [@orangebucket](https://community.smartthings.com/u/orangebucket)\
**Post date:** [February 24, 2021, 9:19pm UTC](https://community.smartthings.com/t/direct-connect-device-button-capability-and-automations/221373/4 "2021-02-24T21:19:18Z")

</div>

> [@nayelyz](#):
>
> Hi, there! I see what you mean, yes, the button value stays as ‘pushed’ unless you change it. Using DTH, there’s a property added to the event to treat it as a state update ( `isStateChange: true` ) even it isn’t a different value.  
> I’m not sure something similar is available in other integrations so, I would suggest you change the value after a small delay.

I notice that the subscription API has a ‘stateChangeOnly’ flag, and that there isn’t any obvious sign of any equivalent of ‘isStateChange’ when generating events via the REST API or in the Schema, not that I can see anyway. I am wondering if there has been a switch from preventing propagation, as was the case in the legacy environment, to filtering on consumption of the events. Although it means more events flying around, the latter seems a much more sensible approach as it lets the user decide what is important.

It would seem strange for the events to be suppressed at the device end, but if they aren’t, where are they going? Automations, as in the bog standard ones in the mobile app, have no problem working with repeated ‘pushed’ events, or any other values come to that.

---

<div class="post-metadata">

**Author:** ![kwanghui](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@kwanghui](https://community.smartthings.com/u/kwanghui)\
**Post date:** [February 25, 2021, 4:56am UTC](https://community.smartthings.com/t/direct-connect-device-button-capability-and-automations/221373/5 "2021-02-25T04:56:15Z")

</div>

> [@bban](#):
>
> @kwanghui Do you know if there is any plan to add a isStateChange like functionally to the direct connected device API?

Hi @bban, I’ll back with some internal discussion. Thank you.

---

<div class="post-metadata">

**Author:** ![bban](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@bban](https://community.smartthings.com/u/bban)\
**Post date:** [March 5, 2021, 3:17am UTC](https://community.smartthings.com/t/direct-connect-device-button-capability-and-automations/221373/6 "2021-03-05T03:17:52Z")

</div>

@kwanghui Do you have any news?

---

<div class="post-metadata">

**Author:** ![kwanghui](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@kwanghui](https://community.smartthings.com/u/kwanghui)\
**Post date:** [March 5, 2021, 4:44am UTC](https://community.smartthings.com/t/direct-connect-device-button-capability-and-automations/221373/7 "2021-03-05T04:44:20Z")

</div>

Hi @bban ,  
Sorry for late response.  
The team decided to expand API to support `StateChange`. I think it would take sometime to deploy on public github.  
I’ll update here when there is an update.

Your observation was great helpful for us. I really appreciate it.

---

<div class="post-metadata">

**Author:** ![kwanghui](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@kwanghui](https://community.smartthings.com/u/kwanghui)\
**Post date:** [March 25, 2021, 12:56am UTC](https://community.smartthings.com/t/direct-connect-device-button-capability-and-automations/221373/8 "2021-03-25T00:56:33Z")

</div>

Hello @bban ,

We have added `stateChange` supported API into the SDK.

> <https://github.com/SmartThingsCommunity/st-device-sdk-c/blob/03f1354cf767b34faf52148c58d4625f5ff04a37/src/include/st_dev.h#L466>

And the button capability sample also updated to use new API

> <https://github.com/SmartThingsCommunity/st-device-sdk-c-ref/blob/302768b7942809df7558510aa704ead77950d6c9/apps/capability_sample/caps_button.c#L143>

Those changes are still in `develop` branch. I think you can use that for your testing.  
I’ll update here when those commits are merged to the `master` branch.

Thanks.

---

<div class="post-metadata">

**Author:** ![kwanghui](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@kwanghui](https://community.smartthings.com/u/kwanghui)\
**Post date:** [June 30, 2021, 8:19am UTC](https://community.smartthings.com/t/direct-connect-device-button-capability-and-automations/221373/9 "2021-06-30T08:19:28Z")

</div>

Sorry for late update. The `stateChange` feature is available at master branch.
