Need Routine to Loop Until I Turn the Trigger Off

have a virtual switch that triggers a routine to do the following:

If switch on

Then

Turn light on

Delay 15 seconds

Turn Light off

Delay 15 seconds

Is it possible to loop back to the beginning of this routine until I manually turn the virtual switch off? The goal is to have a visual alert go off until I turn it off.

I probably shouldn’t answer this while not properly awake, but off the top of my head …

You could add an additional virtual switch, let’s call it loopswitch and make your main routine be triggered by that toggling while switch is on:

if
  switch on (set as precondition)
  loopswitch is on or off
then
  turn light on
  delay 15 seconds
  turn light off
  delay 15 seconds
  turn loopswitch on or off

and then have a starter routine:

if
  switch on
then
  turn loopswitch on or off

and an optional (?) end routine:

if
  switch off
then
  turn light off

Would that work?

1 Like

Can’t loop per se, but using the virtual switch and an accumulated timer, you can get a similar effect. I do this to announce that a door or gate is open every 15 minutes until the door/gate sensor closes.

First, install the Edge Timer Utility found here and create a timer with the appropriate time interval. Next create Routines:

If Switch on (pre-condition)
Virtual Switch Turns on 
Turn on light
Delay 15 seconds
Turn off Light
Turn on timer

If Virtual Switch on (pre-condition)
Switch on (pre-condition)
Timer duration equal or above 15 seconds
Turn on light
Delay 15 seconds
Turn off Light
Reset timer

If Virtual Switch turns off
Turn off timer
1 Like

The visual alert can also be done with an ST App routine. A virtual switch is required for implementation.

The routine will always retrigger itself until the starting trigger condition is removed.


Loop vSwitch can be Cloud Virtual Switch (made using AWA).
When using a Cloud Virtual Switch, the routine works without a hub.

1 Like

Just replied to your reddit post. It’s easy with just three routines, no hub, no custom drivers, no more virtual switches:

  1. If the switch is On, Then “Turn on or Turn off” the light
  2. If the light is On for 15 seconds, precondition the switch is on, turn off the light
  3. If the light is Off for 15 seconds, precondition the switch is on, turn on the light

2 Likes

It seems a few people have done this. Here’s how I did it. I wanted light to flash pink for 2 mins when motion sensor triggered then stop


The water sensor is used because it’s triggered by a non smart guardline outdoor sensor. But it could be triggered by whatever start condition you want.

2 Likes