While loops or repeat loops


#1

I’m having trouble implementing a while or do for so many times.

I want the Piston to pause after the humidity goes above 60% for 8 hours unless it goes about 70%

It seems like I only get the first loop above 60% repeating and it never really gets to the do while loop.

I’m trying to cut down the amount of messages I get. One message when it goes above 60% is fine if it ever gets to 70% then another message would be great.


#2

Not sure exactly your desired effects but it seems like if you use some triggers you can more effectively get the notifications you want. Something like this:

Up to you if you have the wait or just let it notify you at each step regardless of time.

Hope this helps.


#3

What does the exit = 'true" line do?


#4

It stops the rest of the piston from being executed until one of the other triggers occurs. Basically, exit the piston. You need to provide a value for the exit either true or false so I just picked true.


#5

So the Piston will be stuck for 4 hrs when the humidity goes above 60%…then it will check if it goes above 70.

I’m curious why my Piston did not work…I did move the wait 2hrs down to the else in the for do loop so the loop would run for 8 or 10 hrs and see if the humidity go above 70. But I keep getting the response for the first if. I’m missing something on how these loops run.

Keith


#6

I believe the problem with your loop is you are using conditions and not triggers. When you have no triggers, I think it only looks at the first condition for execution so it never gets to your second one. If you change them both to triggers (rises above instead of is above) then it might work.


#7

There’s also the long wait that will probably be canceled by a change in humidity.


#8

I have never used a wait so I don’t know if the trigger will override that although if did wait and the trigger occurred during the wait then you would miss it so either way it wouldn’t work. I think there is a way to check the elapsed time from the last trigger or maybe store the time in a global variable and then not execute the message but you would still be left with the problem of bypassing the trigger and then never getting the next message. Are you concerned the humidity will rise too fast and you will get both messages too close together or you want to give it time to go back down?