I'm working on some major upgrades to the Lutron plugin. One of the open feature requests is a different way to handle double/triple button clicks.
The way it works now is pretty simplistic. The plugin keeps track of the last button press detected with a timestamp. When a button press message is received, any single-click triggers are executed. If the same button press is received within a timeout (currently hard-coded at 1 second), then a "click count" is incremented and any matching triggers (double or triple clicks) are executed. Which means if the same button is pressed three times, each press no more than 1 second after the last, then all three triggers will execute. This is fine for "cumulative" type actions, like adding more lights or making them brighter. Not so good if you want to do totally different actions based on the number of clicks.
It was done that way to eliminate any "timeout" delays. That is, a long delay after a button press before the first ("single press") trigger fires. Using the current time-out, it would be a full second (or longer) before an event would be triggered.
I've been trying to come up with a good way to implement non-overlapping triggers. That is, an "only one" trigger, and "only two" trigger, and so on. And what the appropriate time-out would be. It's got to be long enough that it's a comfortable to press the button, but not so long that it feels like an inordinate delay before execution. I've already re-worked major portions of the plugin to eliminate code paths with timeouts in them. I had to get rid of them anyway to support multiple "gateways" (which is what I'm calling RRA repeaters, Caseta bridges, etc).
Has anyone done anything like this in a different plugin?