RM 4.x - Simple Conditionals for While ... Repeat

RM 4.1 added “Wait for Conditions”. I believe there is a need for “Simple Conditionals Action”. I believe that this isn’t a case of “feature creep”, but instead (please correct me if I am wrong) is necessitated by the RM idiom of “Simple Condition Action”, with “Repeat” being the action, as the only way to do a “While [condition] Repeat [actions]” in RM 4.x.

Yes, there’s a workaround, but it’s unwieldy. The workaround is to have a Boolean local variable, build the conditionals expression, assign to a local variable, use that assigned local variable in the Simple Conditional action. But it has to be done twice, before the Simple Conditional, and again at the end, just before the END-REP. Here’s an example simple rule. Note the 5 actions before the “IF ... REPEAT” and the same 5 actions before the END-REP, both just to build an OR expression. None of that would be necessary if there were “Simple Conditionals Action”.

I had to use a similar workaround in a rule I suggested to someone recently:

So I think I understand the use case. Maybe there's another way I couldn't think of. (This rule also seems like it could have used a "Cancel Wait," which appears to have been removed, and understandably so since it's almost never needed...but again there might be a better way to do what I suggested or perhaps undocumented behavior with repeats that make this unnecessary; I wasn't sure.)

1 Like

I am surprised that you need to use the temp2 stuff inside the repeat to get it to stop.
Any time laststatuscode changes the rule should trigger and run again. Temp1 will get set based on the new status, and doflash will get changed. You are stopping repeating actions and then it will start a new repeat but only if doflash is true. So it shouldn’t need to check the the status again inside the repeat.

As of last September, there was a bug in the stop repeating actions command. It could fail altogether or sometimes you ended up with 2 repeats running. Bruce looked at it and stated that it was broken and he would work on it. See posts 17 and 19 in this thread.
[Motion sensors, retriggers and race conditions]
Maybe it is still broke?

1 Like

You are probably right, but the point of my rule and post was to exactly replicate “Simple Condition Action”, except with multiple conditions, and to show the awkwardness of building a Boolean expression.

In the “Simple Condition Action” idiom that causes “While Condition Repeat Actions”, the initial condition is evaluated upon first entry into the Repeat loop, and also at each re-entry into the Repeat loop.

But thanks for pointing this out. Concurrency is difficult to test.

Edit: I have seen two instances of the Repeat loop running at the same time, though (flashing twice per second). Shouldn’t be able to happen, though, but it has. Perhaps you are correct that Bruce Ravenel (@bravenel) hasn’t yet fixed all the race conditions in stopping repeats.

What you're really asking for is a more full feature Repeat-While action, essentially Repeat-While-Conditions, as it is a contradiction to have "Simple" conditional with complex conditions. I understand your request, and it's no easier to do in RM than what you describe having to do yourself. The beauty (in the eye of the beholder) of the Simple Conditional Repeat to implement a Repeat-While is its simplicity, and that includes what it takes to implement it.

Logs...

To the best of my knowledge this was fixed. Provide logs that show otherwise...

1 Like

Would if I could. It takes almost week of cats pooping in the Litter Robot for the Repeat loop to be entered once, and it doesn’t seem to happen every time. The logs flood with flashing when the Repeat gets entered, so it’s difficult to see except by the observed rate of flashing.

Thanks for the reply, though.

Isolate to the rule itself. I understand though, as chasing down issues in my own system is no fun, just due to size and complexity. Perhaps rethink the automation to simplify...

2 Likes