While Loop Not Triggering


#1

1) Give a description of the problem
I have a While Loop that is not triggering even when conditions are met.

2) What is the expected behavior?
If the level if the specified devices is above 0% I want the While Loop to run.

3) What is happening/not happening?
Logs show the conditions are met but the While statements do not run UNLESS I hit Test.

I know have a condition rather than a trigger but that should be okay as the condition is treated like a trigger due to the absence of any other triggers.

I have also tried this with ‘if switch is on’ and I get the same result.

**4) Post a Green Snapshot of the piston!

5) Attach any logs (From ST IDE and by turning logging level to Full)
11/24/2018, 12:13:42 PM +116ms

+1ms

╔Starting piston… (v0.3.108.20180906)

+1124ms

║╔Subscribing to devices…

+1142ms

║║Subscribing to Study Bookshelf LEDs.level…

+1155ms

║║Subscribing to Study Credenza LEDs.level…

+1374ms

║╚Finished subscribing (252ms)

+1424ms

║Comparison (date) 1543039200000 is_between (date) 1541221200000 … (date) 1546754400000 = true (10ms)

+1426ms

║Time restriction check passed

+1449ms

║Comparison (integer) 5 is_greater_than (integer) 0 = true (3ms)

+1462ms

╚Piston successfully started (1462ms)


#2

Are you sure you want to use level greater than zero as your condition? A device can be switched off and still have a level greater than zero. You might want to use the switch part of the device as the condition for the while loop.


#3

In the device handler I am using the level sets to 0 when turned off. Even if it did not I would have expected the while loop to run as level would be set to 5%.

As I noted above, I have already tried using ‘switch’ as a condition but I get the same result.

Since posting above I have also tried an IF, THEN, REPEAT version with switch as a condition and again it will not start the loop until I hit TEST.


#4

Try taking out your date restriction and see if that fixes it. That’s the only thing I can think would cause it. I have almost the exact same piston except for the dates and it works fine.


#5

Good idea. Tried but still no dice.


#6

Wait…are you waiting for the random to be complete? It looks like the piston has started correctly. You would have to wait up to 2 mins for the next part to complete.


#7

None of the statements in the loop are starting until I hit test. The wait timers were not even starting.

I solved it. Even though the actual ‘trigger’ is a condition, the piston does not fire the loop until the device switch turns on after the piston is already running. In other words, if the device is already ON when the piston starts (from my editing and saving) the loop does not start. It’s a bit counter intuitive to me as the piston simply says if switch is ON, not if changes to ON.

With the piston running, if I cycle the devices off then on then all runs as expected.