Cancel wait

Does cancel wait have to be before the wait?

Does cancel wait assume the wait conditions are met (ie, subsequent actions are run) or wait conditions not met, and subsequent actions are not run?

Well, if it's after the Wait how would it ever happen? I could be in a different branch of an IF-THEN-ELSE and the rule is triggered a second time, much like Cancel Delay is used.

It only does anything is there is a pending Wait.

Ok, so lets say that there is a pending wait, coupled with a cancel wait, and the cancel wait conditions are met. Do the actions subsequent to the cancel wait get actioned as if the wait for event(s) occured, or not?

A Wait action puts subscriptions (or schedule) in place and then exits the rule. The only way that rule gets restarted for the actions after the Wait is if those subscriptions (or schedule) fire. Cancel Wait removes the subscriptions (schedule). So, those actions will not run after that happens.

1 Like

Thanks Bruce.

@bravenel Does "cancel wait" remove all the subscriptions (I mean, from any rule) or does it only remove the subscriptions from the same rule it is inserted into?
if it does indeed work only within the same rule, is there an alternative for me to use a command that will "cancel wait" on a different rule (kind of like we can use the '"pause rules" feature.
Thanks

It only applies to the rule it is inserted within.

Cancel Rule Timers will cancel pending Waits in another rule.

2 Likes

Thank you so much @aaiyar and @bravenel

Cancel rule timers will also cancel all periodic triggers that are scheduled for that rule. So, if you have a rule that is triggered at a specific time or sunrise/sunset you will have to go into the rule again and click done to get the schedules back. Correct Bruce? This might not affect your particular rule just want to make sure that folks are aware of limitations of the command.

This is correct. It should also be pointed out that when a rule is triggered, any pending Wait is cancelled.

I've been thinking about this feature. Perhaps Delay Actions should work the same way; that is, any pending Delay Actions (which delays all following actions) should be cancelled if the rule is triggered again., or perhaps this should be the case with Cancel selected. Most uses of Delay Actions end up in an IF-THEN-ELSE where the other side from the Delay Actions has a Cancel Delayed Actions. So why not just do it automatically? This would fix the issue of simultaneous rule instances also. Thoughts?

It makes things simpler but then also takes away some flexibility. I would definitely suggest that you only do it for delays that have cancel selected. Some folks use delay along with PB to prevent a rule from firing twice. Canceling those delays would cause the logic to not work anymore.

I'm sure you don't want to hear this suggestion, but I'll throw it out there. Having an option in the triggers page to cancel all delays and waits upon re-trigger while maintaining the current actions of cancel delayed action and stop repeat would be the most flexible and simple for newer users. Although, I acknowledge this is the most complex from an implementation standpoint.

I'm trying to understand Cancel Wait and how it would be used so I created this simple rule. Seems to me that the delay on the Cancel Wait should kill the subscription to the door contact sensor but it doesn't. After the Cancel Wait, the rule is waiting for the Door Back to open and sends the notification when it does. Am I applying this wrong or is this a bug? No trigger, just using Run Actions.

image



That's odd. I will look into it. I agree that it should have canceled the wait. BTW, you can put a timeout on the wait itself to accomplish the same objective.

@pseudonym Are you trying to not perform the events after the wait or end the wait early? Because there is a timeout built into the wait so that it doesn't wait forever. That I know works correctly.

What it appears that the cancel wait is doing is unscheduling the wait's timeout but not unsubscribing to the wait device, which is definitely not what it should do.

Canceled the wait as in performed the actions after the wait early or not performed the actions at all? Because cancel a delay cancels the actions after the delay. I would think that canceling a wait would not performs the actions after the wait. The timeout on the wait performs the actions after the wait but I didn't think that cancel did the same thing. To be honest, I never even tried the cancel before.

Since a Wait is already canceled when a rule is re-triggered and you have the ability to add a timeout to a Wait, I'm not sure what purpose the Cancel Wait has. I'm not trying to apply it to anything in particular, I'm just trying to understand where or how one would apply it. My rule was just to increase my understand of this particular action. Adding a delay to it was the only application I could think of where it would have any use at all. Just happened to stumble across this possible bug in the process.

If anyone has an example using a Cancel Wait, please share.

It looks like " Cancel Wait" was taken out of Rule Machine 5.1, unless it moved somewhere I haven't been able to find it. I have a washing machine rule that has two halves: the first is if the washer goes below a threshold and the second is if it goes above a threshold. See below. I was using a "delay actions (cancelable)" in the first half and then a "cancel delay actions" in the second, but I was reading that the wait for event --> elapsed time was better because if I get two or more updates below the off threshold then the subsequent waits for event automatically cancels the previous waits (great!). But now if the power goes to the "on" threshold (the ELSE-IF portion) after the "off" threshold was waiting for the elapsed time event, how can I cancel that wait without "cancel wait"?

Edit: it looks like Rule Machine 5.1 documentation is just a place holder right now (https://docs.hubitat.com/index.php?title=Rule-5.1), so I did try to read about this function there first. I'm guessing someone in the know will tell me that "cancel delayed actions" now cancels waits as well as delays (or always has) so there is no reason for "cancel wait".

"Cancel Wait" was removed some time in Rule 4.x because it was hard to think of a time when it actually did anything. A re-trigger will cancel all waits, and that's normally all you will need need (and normally all that is possible; if the rule is waiting, it's hard to get to a "Cancel Wait" action).

So, "Cancel Delayed Actions" does not affect waits, only "Delay" actions marked "cancelable," but it's unlikely you ever needed to cancel anything at all. :slight_smile:

2 Likes

Sweet! Thanks.

'Cancel Rule Timers' for 'This Rule' does cancel waits, and delays and repeats.

2 Likes