Repeat action every X minutes until the condition cease to exist


#1

Basically I am looking to do quite a simple thing, if a contact is open and stays open, send a notification every X minutes until the contact is closed. For HE RuleMachine, there’s a simple “cancel if truth changed” option, which cancels the statement altogether. For WC I am not sure what the design should look like.

if (device.contact is open)
repeat
wait 5 minutes;
if (device.contact is open)
notify
until device.contact is closed

Is that the right line of thinking? What if I want to have

any of device1.contact, device2.contact, device3.contact is open - there we run into hairy parallelism issues which I would rather avoid dealing with.


#2

Enable the Advanced Statements under Options if you haven’t already and you should get While and Repeat statements.


#3

I get the statements. I guess the problem is, if a contact closes while 5 minute wait is going on, I want the wait to be terminated and the piston to finish right there, so basically “wait until contact closes or 5 minute expires, whichever happens earlier”


#4

Oddly enough. I have a piston that I wrote to tell me if a door has been open for more than 2 minutes. I expected it to nag me once. I nags me approximately every two minutes that the door is left open. I say approximately because sometimes it takes up to five. Here’s the piston I’m using:


I’m going to work on it today to see if I can get the nag more time-reliable. I’ll let you know.


#5

Hm, are you suggesting that the contact flag resets after the wait period triggers an action?


#6

That seems to be the case. I’m not resetting it in any way.


#7

My garage door notice is also acting this way, even though I didn’t program it to. I’m not complaining, though. It’s a nice, unexpected, outcome.

If the garage door stays open for 30 minutes, certain lights will turn RED and 100% for 5 minutes. If the garage door stays open for 60 minutes, certain lights will turn RED and 100% for 5 minutes, and Alexa will announce “The garage door has been open for one hour, please check the garage door”.

The 30 minute and 60 minute pistons repeat if the garage door is still open.

Again, not complaining…


#8

ended up doing this


#9

What does your execute piston do?


#10

It will execute another piston from within the current one.


#11

Yes what is that other piston?


#12

It’s up to you. You can choose from all your existing pistons.


#13

I just meant what does your do (why did you pick that one for this repeat)?