Has to be easy but I'm making it difficult

Trying to setup a Repeat While to run 3x but I want the delay to be inside the loop. So I do not want to specify a delay on the Repeat itself. Seems like one is required.

Just trying to loop everything within a section 3x.

Since it's just 3 I can do it with multiple IF statements but it seems like there should be a way with repeat. I have a wait for event elapsed time within the While but it still goes back up and fires the entire repeat again. I guess I could also put a delay on the while that is equal to the total time of delays within the loop but I was just surprised it didn't wait until it naturally got to the END-REP to start over.

Showing the current rule along with a plain language description of what you're trying to do would help.

1 Like

Think I figured a way around it.

I have an Ice Tea maker that when it finishes brewing I'm trying to get not only a push over notification but also an alert from Alexa via a virtual switch that I am turning on.

The rule looks like this:

I was having a challenge the first way I had it to not get a double notification from Alexa. So now I have the 20 minute sleep to let the initial brew finish. Then I turn on the virtual switch for Alexa and send my first pushover notification. I want to wait 10 minutes and then repeat the notifications.

What seems counter to me is that the While loop requires the time delay. I have the delays I need within the body of the Repeat. If I just put a 1 second delay on the Repeat I get 3 fast alerts from Pushover as it seems like the Wait for Event Elapsed times are ignored. So I added a time delay for the entire loop. I get the reason to have it it just seems that it should not start the next loop until the first totally finishes.

Running a test now of that one to see if it will do what I need like that.

2 Likes

Totally share your hand-wringing over the need for that "Repeat Every" interval, but once I started thinking of WHILE as "spawning actions" (agnostic of what's inside the loop) it started to make more sense to me.

I might suggest you considering modifying your rule so that WHILE tests against the condition "V-Tea Done == On" instead of the var counter (which could be entirely eliminated if you weren't using it in the Pushover step). At least that would allow you to delete the "Exit Rule" conditional.

But hey, if it works as-is, great. I'm all for "belt and suspenders" approach to rule design! :slight_smile:

Think it is now so I'm not going to fool with it anymore. But it still seems that if you have a wait for elapsed time within that loop it should not finish the loop until that is done. It would be up to the user to correctly use it if no delay on the over all repeat but as long as I see what it's doing I can add it all up and set it accordingly.

Also I can't test for that as I need to turn it off and on between passes in order for the Alexa routine to send verbal notifications every 10 minutes after the first one. But now that I type this I suppose the Private Boolean could be used to help out here but again it's working as it is now so NO! NO! NO! just leave it alone! (Why do we love to tinker?)

I'm not 100% (someone like @bertabcd1234 would know better) but I believe the While-Repeat is a scheduled job. Meaning, it evaluates the condition and, if true, schedules another check in 10 minutes and moves into the loop. Wait for events are also scheduled jobs that are unscheduled the next time their invoked.

So you are saying:
IF(counter is <= 3) THEN { do the below actions and check again in 10 minutes }

I'm pretty sure you've got some overlaps in how this rule runs. I think you'd have been alright with:

Trigger: "whatever you're using...guessing it's a power reading off the outlet"
Action: 
Wait for event: 'Power level of outlet < 20 and stays that way for 0:20:00'
While ("insert whatever indicates you've acknowledged the tea is done") repeat 3 times every 0:10:00
	On: 'V-Tea Done' (is this the Alexa notification? Just set the switch to "auto off after 1 second")
	Notify Pushover: "Tea time"
END-REP

If you want the alerts no matter what, you can just change the "repeat while" to a regular "repeat."

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