RM Example: STAYS trigger (it's really not a trigger...)

I've seen a handful of people asking recently about the lack of a STAYS trigger in RM. Technically, it is accurate that there is no "STAYS" trigger in RM. Conceptually though, STAYS really isn't a trigger so much as it is a condition that lasts some minimum amount of time. I'll contend that STAYS really is a pretend trigger that "happens" after a condition exists for a certain amount of time.

I can take the statement "I want to turn on a switch if the gate stays open for 10 minutes" and rewrite it as "I want to turn on a switch if the gate is open for 10 minutes". They mean the same thing. And in logic speak, "is" is a condition.

If you want to make a rule to replace a "STAYS" trigger, think of it in the "is" context.

Here's a sample (and simple) rule to turn on a switch if the gate stays is open for 10 minutes. The key here is to enable the Cancel on truth change option, this prevents the actions from happening if the gate closes during the 10 minute delay window.
image

  • Conditions
    -- Gate contact is open
  • Rule
    -- Gate contact is open
  • Actions when True
    -- Delay 10 minutes (Cancel)
    -- Turn on the switch
7 Likes

thank you! I did not see the delay cancel change added that just fixed a problem I had with 2 of my announcement rules that was driving me crazy for a long time.
I think they are using zigbee and zwaves to read my mind!
.... damn it that was a short drive I am already there

2 Likes

Glad it helped.

To understand how things work, if you did not have the Cancel option enabled, what would happen is every time the gate contact opens, a new action would be scheduled to happen 10 minutes later, without changing the previously scheduled actions.

Let's say you are in and out of the back yard through the gate, and you open it and close it behind yourself each time.

Without the Cancel option enabled
Gate opens at 6:04 - rule is true and actions are scheduled for 6:14
Gate closes at 6:05 - rule is false, nothing happens
Gate opens at 6:06 - rule is true and actions are scheduled for 6:16
Gate closes at 6:07 - rule is false, nothing happens
Gate opens at 6:09 - rule is true and actions are scheduled for 6:19
Gate closes at 6:10 - rule is false, nothing happens
Gate opens at 6:12 - rule is true and actions are scheduled for 6:22
Actions run at 6:14
Actions run at 6:16
Actions run at 6:19
Actions run at 6:22
Gate closes at 6:25

With the Cancel option enabled - it's a little different:
Gate opens at 6:04 - rule is true and actions are scheduled for 6:14
Gate closes at 6:05 - rule is false (truth change), cancels 6:14 schedule
Gate opens at 6:06 - rule is true and actions are scheduled for 6:16
Gate closes at 6:07 - rule is false (truth change), cancels 6:16 schedule
Gate opens at 6:09 - rule is true and actions are scheduled for 6:19
Gate closes at 6:10 - rule is false (truth change), cancels 6:19 schedule
Gate opens at 6:12 - rule is true and actions are scheduled for 6:22
Actions run at 6:22
Gate closes at 6:25

2 Likes

That's a really great description. Easy to understand.

1 Like

If there is more than one action, will it wait the 10 minutes before doing ALL the actions?

Yes, that's correct.

So in this app/piston/rule I have the delay of 10 minutes to give time for any other activity. But if there is activity I don't want the other Actions to take place. In other words, if motion is active during this 10 minutes, none of these Actions will fire? (Is this correct?
image

Looks correct to me. If a motion sensor goes active, the rule changes from true to false and because you have the Cancel on truth change option selected, it will cancel True's actions.