Hey Guys I need some help with a rule to turn some lights on, I want the rule to keep trying until the lights are on.
Below is my code which still seems to fail sometimes, so I was wondering if the code is not correct ?
IF (Bedside Lamp 2, Bedside Lamp 1(on, on) any is off(F) [FALSE]) THEN
On: Bedside Lamp 2, Bedside Lamp 1 (Command only switches that are off)
Repeat 10 times every 0:01:00 (stoppable)
Until (Bedside Lamp 2, Bedside Lamp 1(on, on) all on(T) [TRUE])
END-REP
END-IF
The repeat is in the wrong position. I think it needs to be further up. It will only repeat the actions between the 'Repeat 10 times...." and the 'End-Rep' I think.
IF (Bedside Lamp 2, Bedside Lamp 1(on, on) any is off(F) [FALSE]) THEN
Repeat 10 times every 0:01:00 (stoppable)
On: Bedside Lamp 2, Bedside Lamp 1 (Command only switches that are off)
Until (Bedside Lamp 2, Bedside Lamp 1(on, on) all on(T) [TRUE])
END-REP
END-IF
Well the Until would stop it going on repeating once the lights were already on. If you don't mind the rule trying to go on turning them on for no reason then the line can go.
On second thoughts maybe you do need it. What if 5 minutes after turning them on you wanted them off and turned them off manually. The next time round the loop they'd come back on again.
It's safer to have some limit on the repeats as it prevents tying the hub up in knots. You could increase the number of repeats, or at the end of the rule test once more if the lights are not in the right state and then send a notification so someone can see what's wrong.
Just replace the six lines in the OP with the three lines of this while loop and you should be gtg. Note that the IF of the while loop is a simple condition and not an IF-THEN.