Breaking out of a "wait"


#1

1) Give a description of the problem
I have a loop that tests to see if a door contact is open, if its closed it turns a light on one color, waits 5 minutes, turns it another color, waits 5 minutes, and repeats. I have another asyncronous statement that turns the lights off if the door contact changes to open. Opening the door during the second wait sequence turns off the light and when it tests the door condition again, it exists. However, if the door opens while in the first wait sequence, when the first wait sequence ends it turns the light back on, even if the door is open. I can think of a couple of ways of resolving this, but everything I’ve thought of is kinda messy, was hoping there was an easy one or two line statement I could make that would fix it.

2) What is the expected behavior?
Opening the door turns the lights off and keeps them off until the door is closed again.

3) What is happening/not happening?
Light is coming back on after the first wait sequence

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach any logs (From ST IDE and by turning logging level to Full)


#2

You might have better luck with a ‘while loop’ instead of ‘repeat’… the following simplified example works nicely: