Repeat until...?


#1

How to repeat until?

I want to push a button - a light sets level to “variable - 1” (variabel is set to light level)
I want this action to repeat undtil light level i 1.

Then the light should turn of.

My only problem is, I have no idea how to repeat the “variable minus 1 action”?


#2

sounds like you want to use a for loop:

for Light_level to 1 step -1
   with dimmer
      wait
      set level to $index
   end with
end for
with dimmer
    turn off
end with

If this is too cryptic let me know and I will try to explain in more detail later.


#3

Also make sure Advanced Statement is enabled under Options when in Edit mode.


#4

That’s to advanced.
This is my first piston.
I’ve done coding on a very basic level.

My problem is, I don’t know how to get the “loop” command to “appear”.


#5

As @eibyer mentioned above, you need to have advanced statements enabled. You do that in the editing window by clicking options in the upper right corner and checking the box.

Once that is set you will see all the available statements:

You want the for loop for this case. The for each is for going though a list of devices.