Repeat rule until change

Is there a way to have a rule run repeatedly until a change? By way of example, If “Basement Door” stays open for 10 minutes, Text XXXX a message. wait 1 minute repeat unless door has been closed.

Thoughts?

Use a variable set to true false.
Here’s an an example of my refresh every 15 min rule. I can then use this variable changing state in multiple other rules.

Here’s of another example with a variable that sets a loop.

I don’t understand how the variable would work. The delay and then changing the variable back to true really doesn’t mean the door is still open. What am I missing here?

Let’s name the variable $isDoorOpen

I have my door left open rules split into 2 rules.

Rule 1
Trigger
Door changes to open
Door changes to closed

IF
Door is open

THEN
Set $isDoorOpen true

ELSE
Set $isDoorOpen False

Rule 2
Your triggers will be
$isDoorOpen stays True for 10 mins

IF
$isDoorOpen is True (triggered from Rule 1)

THEN
Send message
Set $isDoorOpen False
Set $isDoorOpen True. (this triggers the rule to run again. It will check if the variable is still true and go to the THEN, if the variable is false it will move to the ELSE)

ELSE
Set $isDoorOpen False (this stops the loop)

1 Like

Sorry. I edited it because my first post wouldn’t have worked.

Thank you!

Since I’m losing WebCore at the end of the year, I’ve got to duplicate over 100 Pistons. I’m learing with the easy ones first. Some of my complex Pistons may not be able to be replicated…

I just did this so if I can help let me know.

You can put my above example in 1 rule by combining the triggers and using 2 separate IF statements but I’ve found it’s easier to trouble shoot when I set the variable by a separate rule. Plus I can also use them in other rules.
Sorry again for the rewrite.

1 Like

I’m not quite getting this. I guess I’m still committed to WebCoRe logic. Does the first rule just get “burred” in the rules list? It looks like the second separate rule does the work. I have many Pistons that do something similar by “watching” something until “it” changes. I’m just not sure Sharptools is my best option for solving the pending SmartThings / WebCoRE issue…

1 Like

No worries. Switching from webcore requires a new way of thinking.

Yes, the work is done in Rule 2. Rule 1 is basically just to poll from.

All the first rule does is set the variable to true or false based on the door being open or closed to be used on other rules.

The second rule is triggered once the variable stays True for 10 mins
It runs the logic by first checking to make sure the variable is still true (you didn’t close your door in that 10 min wait) and then does stuff because the door is open.
Set the variable to false and then back to true to restart the 10min wait.
Once it reaches the stays True for 10 mins it runs the logic again.
You don’t really need the else because if the door closes the variable will be set to false by rule 1.

I’ve been able to transition 99% of my webcore pistons over, everything except the ones with time calculations but it did take a lot of variables and thinking about it slightly differently.

Hopefully I answered your question.


As an example of using the variable in other rules; I created the Rule 1 for all my doors and windows. I then have another rule with another variable $allDoorWindowsClosed. I use the variables from each door & window as a trigger and condition for this rule and then display $allDoorWindowsClosed on my dashboard as a tile. Now I can see if any door/window is open without having multiple tiles on the dashboard.

So… Basically… The first rule is really acting like a virtual switch?

Yep…correct…had to meet 20 characters :grin:

Do you use Pushover for notifications? I’m trying to figure out how to add 2 or 3 devices to the rule for notifications. So far I can only get mine in there. Used to be so easy in WebCoRe

I’m not sure what issue you’re having exactly but to add to a rule you’ll need to add each phone notification as a separate action in the Then part.

I believe you’ll need to slightly change the body or they don’t always go through. There was a conversation on the forum about this but can’t find it at the moment.

The issue I’m having is not being able to figure out how to get the second device integrated so I can select it.

@josh Can you help with this?

Using your previous assistance I created a rule that will do the following (I hope):

When the “Fan Switch” is “ON” turn on the “Blower” and cycle it on and off every 10 minutes as long as “Fan Switch” Stays “ON”. If “Fan Switch” is “OFF” shut off “Blower”.

I cannot test this until winter as “Fan Switch” is controlled by a thermostat. Does it look like it will work?

You’ll need to add fan switch changes to off as a trigger.

And then yqou can keep the second If/then section and add below blower off, set variable False or you can move Blower off and add set variable false to the Else section so it’s ready for the next run.

Otherwise I think it looks ok.

Like this?

Thanks for the tag. I’ve been responding over in the other thread @JKB121 created. :slight_smile: