How do I include “If x is off”?

Hi there,

How do one trigger a automation if x is off?
Not really switches to off but rather is off.
Some automations fail to run in my home so I have to make some failsafe automations… thanks samsung for making most worse than before :dotted_line_face:
My automations is slower now when local than before when cloud based and used webcore…


A few options:

Create a routine with the “stays this status for XX’ time” option. For instance, stays with no motion for 2 hours, run this.

You can create a “watchdog” using two virtual switches that will start in XX seconds/minutes/hours and then cycle every YY seconds/minutes/hours after that, allowing you to run logic on that period to check for status or run other routines.

  • Create one virtual switch, we’ll call it “Enable”. This will enable and start the watchdog timer running.

  • Create a second, we’ll call it “Timer”. This will keep track of the cycle time and can be used to trigger routines periodically to check/run stuff.

  • Add a routine,call it Start Watchdog
    IF “Timer” is OFF(precondition)
    “Enable” turns ON
    Turn “Timer” ON, Turn off after XXX seconds/minutes/hours

  • Add a routine, call it Cycle Watchdog
    IF “Enable” is ON (precondition)
    “Timer” turns OFF
    Turn “Timer” ON, turn OFF after YY amount of time.

This means that turning “Enable” ON will start the turn on “Timer”, turning it off after XX amount of time. When “Timer” turns OFF, it will check to see if “Enable” is still ON, and if so, it will turn itself ON turning OFF after YY amount of time.
This way you can have an initial timeout and subsequent timeouts.

Simply turn ENABLE off to stop the watchdog from cycling.

You can then trigger routines on the “Timer” virtual switch going on or off to check the state of anything else you like and control it accordingly doing any action a routine will allow you to do.

To test it you can create a routine that cycles a light on and off every time “Timer” turns on or off. Its fun for the whole family!


That’s what pre conditions are for. But I guess your problem is you need a triggering event to cause a Routine to fire… ?

If all you need to do is check if a device is current on/off, you can use a precondition like in the example below. If you need something more complicated, you can do as @csstup suggests using mulitiple routines.

1 Like

Imagine that the “that” in your if this, then that, rule is a siren sounding.

“porch light is off” can’t by itself be a trigger condition in any home automation system, because “is off” isn’t an event. It’s a state. A trigger has to be an event.

Now you could combine it with checking, say, every minute, or every 15 minutes, and have the siren go off because the porch light is off when you go to check it. But going to check it would be actually triggered by the time interval.

That’s what people are describing with a pre-condition of the porch light is off. If the porch light is off (state) and a trigger event occurs (like a specific time or a specific time interval, or someone arriving home, or the door being opened or whatever event you were using) then state could be a filter on that rule happening, if the door opens and the porch light is off, sound the siren. But there has to be an event to be a Trigger.

Would it work for you to check if the device is off once a day or once an hour or something like that?


At most once every hour I would require it to check the state.
I have a real switch going on / off once every hour and this switch enables or disables routines, but if switch is off the second hour im not getting a routine to run since its already off.
There’s a homey integration that turns this switch on / off once every hour depending on electricity price.

I also wonder… does having virtual switches make smartthings run slower? Or amount of automations? I dont have alot of devices but virtual and automations are stacking up and its already slow to run automations and turn on / off lights and such even in local

Do it similarto the way i recommended above and it will off then on again every hour, instead of just toggling on for 60 minutes, off for60 minutes.

Or half your cycle time to every 30 minutes with your existing implementation.

1 Like