Trying to achieve DO-WHILE and REPEAT in RM 5.0

Objective: cycle two different strings of Christmas lights on Bruce the Spruce via a dual channel relay (for next year)

Question: does the time condition of the IF stmt get continually evaluated as written and is therefore able to STOP the REPEAT, or is that REPEAT command just going to go on infinitely? When I first went into this I was looking for a way to REPEAT-while that time window was TRUE but it seems I have to wrap it with the IF.

Thanks in advance for the look over.


IF (Time between Sunset+35 minutes and 21:00(F) [FALSE]) THEN
Repeat every 0:31:00 (stopable)
On: Lights - Bruce - Relay - Dual - EP01
Delay 0:15:00
Off: Lights - Bruce - Relay - Dual - EP01
Delay 0:00:10
On: Lights - Bruce - Relay - Dual - EP02
Delay 0:15:00
Off: Lights - Bruce - Relay - Dual - EP02
END-REP
END-IF

Couldn't you just have the rule triggered at a specified time and then nominate the number of repeats? Like this:

I am turning other lights on (triggered by a start time) before this part of the rule, but I see how you used the REPEAT and yeah, that's the idea...on/off/on/off but what stops the bus here? Not seeing how it ends? I was not wanting to set a fixed number of cycles in that time window. Thus the IF with the time condition.

You could split the rule to account for other lights / actions being performed, depending on how you solve this repetition issue.

My suggestion around the repetition and the timing does depend on whether you are going to trigger it consistently at the same time. So if you were to trigger it at Sunset+35 each day.... Hmmm... that can change, can't it.... Well, to complete my train of thought, if you triggered it at say 5pm each day, through to 9pm, you could calculate the number of 31 minute cycles you want to run through and set this in the number of repeats, like I did when I set mine to run twice and then stop.

In my rule, it starts at 2:30pm, runs through the repeated actions once at 2:30:00, then again at 2:30:20, then stops, as I set the repetitions to 2.

Hopefully someone else may have a better idea than me, otherwise maybe a fixed time period could be the go?

Actually, what if you setup a separate rule to stop the lights at 9pm? So the rule you have shown starts the repetition, but a separate one runs at 9pm to stop / cancel it? Not as elegant, I know...

This thread may also be worth a look, and am thinking you could use the IF condition at the end with stop repeating actions, shown in the screenshot of the documentation on this post. So:

Repeat every 0:31:00 (stopable)
On: Lights - Bruce - Relay - Dual - EP01
Delay 0:15:00
Off: Lights - Bruce - Relay - Dual - EP01
Delay 0:00:10
On: Lights - Bruce - Relay - Dual - EP02
Delay 0:15:00
Off: Lights - Bruce - Relay - Dual - EP02

IF (Time between Sunset+35 minutes and 21:00(F) [FALSE]) Stop repeating actions

END-REP

1 Like

Yes, of course! That's the way to go... and puts the evaluation and resulting action where it needs to be. Note my revision to NOT this condition. And that's a good discussion in that thread JUST happening! Thanks for that!

2 Likes

Download the Hubitat app