Groups within Rules

I’m just starting to work with groups with rules, in order to reduce the volume of replicated code as well as the total number of rules.

I found the following code snippet while researching this topic. Here the door name is used to create another related item name “timer”. Close to what I want to do but not exactly.

// if(door.state == OPEN) sendCommand("_Timer", "ON") // else postUpdate("_Timer", "OFF")

I need / want to do something similar to the above, but inside of a logical statement…like the following code snippet. Can this be done? If yes, what is the correct syntax? Also, is there somewhere this is documented, as I would like to study and bookmark. TIA.

while ( ((i=i+1) < 10) && (mbr+"_DownPower".state == ON) ) { Thread::sleep(1 * 250) }

In the likely event that I have lost my mind, alternate approaches would be appreciated.

See Design Pattern: Associated Items. Pay attention to the Item Registry approach to pull an Item based on its name.

If you are on OH 2.x, a rule that takes that long to run can cause problems. Use a Timer instead. It’s not ideal in OH 3 but it won’t cause problems as written.

I will study the section you referred.

Timer will absolutely be used. I leave the code inline for development, then switch to Timer.
I am familiar with the number of available threads, thread locking, delay, thread::sleep, etc.
Still, I appreciate your checking, as I failed to point out why I didn’t have a Timer.