Stop Repeating Actions

I have seen other examples of using "Stop Repeating Actions" like this on the forums, but I can't figure out what's different about mine that breaks it. This rule correctly cycles through colors on my lamp, but releasing the button does not stop the cycling. Looking in the logs, the release action is recognized and the logs even say: "Action Repetition stopped". But it doesn't stop. It goes right on with the loop and always executes 20 times. Anyone have any ideas on what I've done wrong? Or maybe someone has a better idea of how to cycle through colors while holding a button and stop when I release it?

The "Stop Repeating Actions" must be in the same actions section; one for a different button event in the same rule will not work for other button event actions sections. One way around this is to use separate rules--regular "Button" (not "Button Device") rules--where you can use "Stop Repeating Actions" on another rule.

I should note that rules like yours did actually work at one point, but that was considered a bug (each actions section is supposed to be completely independent) and was fixed in, I think, 2.2.4. So, if you saw a rule exactly like this and it was claimed to work, that is one explanation.


Thanks, I definitely saw examples like this claiming to work, so that explains it. I'm not sure I fully understand your suggested workaround. Are you saying that "Stop Repeating Actions" will work across rules? I didn't think that was the case. If so, do I have to tell it which rule to stop?

Alternatively, I thought of using a regular "Button" rule triggered by all states of the button, and then use if statements to determine if it was a "Held" or "Released". But is there a reliable way to determine which button state triggered the rule in this case?

Sorry, I recalled that a bit wrong! To stop a repeat on another rule, you'll have to use the "Cancel Rule Timers" actions instead. This does a lot more than stopping a repeat (it warns you about all of these things in the UI: delays, periodic triggers, etc.), but in the example above, the repeat should be the only affected action--and it does let you choose another rule, so it would work here.

You could do what you're suggesting with a single "Button" rule too, but it's a bit kludgy. RM has built in variables:

  • %device%: the display name of the device
  • %event%: the name of the attribute--like switch, motion, or here, pushed, held, released, or doubleTapped
  • %value%: the value of the attribute--like on or off for a switch; for a button event, this is the affected button number

So, you could probably build conditionals that check those things instead. Using another rule is probably less clicking. On a related note, staff indicated that they plan to re-do how RM handles button devices at some point in the future, but there is no timeline for that--but whenever that happens, if it happens, you may have an easier time then.

1 Like

Thanks for your help. I was able to get it working with the "Cancel Rule Timers" approach. I did play around with the built-in variables, but although the other variables had the right values, %event% was always null (which is the variable I needed). But the first approach will work fine until the RM button rework.

I just had the exact same issue - copied forum examples for stopping repeats when button is released, but they didn't work!
Here's what I did to fix mine in a single button rule - used custom local variables to stop the repeating action when each button is released:

1 Like