Device event: button works only once

The push button works only once. I have sent the event several times and everything seems to be going OK, but the event is not delivered.

            deviceEvents = [
              {
                component: "main",
                capability: "button",
                attribute: "button",
                value: "pushed",
              },
            ];

All other events seem to work OK.

The default behaviour of SmartThings is to only propagate state changes. So if you had a sequence on / off / off / on / on / on only on / off / on would make it as far as event handlers. With the button the sequence is pushed / pushed / pushed … so only the first pushed gets through.

There should be a flag you can add to an event to indicate it should be treated as a state change even if it isn’t. With an Edge driver is described on Capabilities — SmartThings Edge Device Drivers documentation. There will be an equivalent for other device integrations. I think for the API Create Device Events call it is probably the pair state_change: true in the event data.

I tried this, but it won’t accept the whole event. Returns an error.

            deviceEvents = [
              {
                component: "main",
                capability: "button",
                attribute: "button",
                value: "pushed",
                data: { state_change: true },
              },
            ];

I am probably getting confused and it isn’t actually part of the data. It really ought to be allowed for in the API though if it isn’t.

I solved that by sending the command “down” after two seconds. Now pressing the button sends two commands, pushed and down. That state_change would have been a better solution, in which case it would have been possible with one command.