How best to cancel a delayed action?

I have a button that initiates a 2 stage alarm sequence..

Single push, plays sound # 10 (soft beeps). Then sound #9 plays after 5 seconds. This is the alarm sequence.

Double Tap, turns off siren (intended to cancel the whole alarm sequence)

My problem is that when i double tap the button before the 2nd stage alarm, it turns off the first sequence only... but the second sequence proceeds to play after 5 seconds. It's like the list of actions still proceeds...

Worst part is that if I single push the button 2 times, i get duplicates of the 2nd sequence...

What I think is happening is that the delay gets scheduled, but since the button press is coming from another sub-rule, it is not cancelling this one.

As for pressing twice, yes, it will re-start the rule and the wait for 5 seconds will be scheduled a 2nd time, so it will run sound 9 twice. To avoid this, add a “Wait for event - elapsed time - 5 seconds” before the 2nd action and remove the delay.

To cancel the rule, I would try adding in the other button a “Pause Rule” action for the rule you shared, followed by an enable rule after something like 5-6 seconds. There would be multiple other ways of doing this.

1 Like

hi
tnx. I'll give it a try but this method sounds convoluted . Isn't there a way to cancel the rule progression anytime? i thought that's what the "cancelable" option is for.

Yes, a cancel can be added within a rule, but in the case you are looking at, I’m not sure it would work. That said, there are always multiple ways to do things in Hubitat, so there is likely a better way!

yeh, i wish there was just a CANCEL RULE option and I'd be done with.

How about using variables? Is that possible? like I can put a condition to make sure

IF

$play_rule = 1

Then

Proceed with RULE ACTIONS

else

STOP

then I can set that variable globally.. just a theory atm, but possible in HE's global variable feature? I havent played with variables yet, tbh.

Yes, that is probably a better approach. Can use a switch or global variable for this.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.