Turn the switch back ON after x minutes OFF

@geesantoso,

I’ll have to look some more into the virtual switch but I wonder if a physical switch would be helpful (placed close to the aquarium)? Seems like you could press the button to turn off the filter for 15 minutes and then turn power back on.

https://www.lowes.com/pd/Iris-Next-Gen-White-Wireless-Home-Automation-Button/999925306

Good luck!!

-Patrick

@JDRoberts answer is great and accomplishes the original task very well. However, if you are using something like the Amazon Alexa, this setup leads to an awkward trigger syntax. i.e. when I want to turn the fish take filter off for 15 minutes, I have to tell Alexa to “turn on Feed the Fish” (my virtual switch name). This might work for some situations, but others work better with a “turn off X” command.

Luckily, JDRoberts’ instructions only need a small addition to make this work.

  1. Use Smart Lights to turn ON your virtual switch when the real switch turns OFF
  2. Use Power Allowance to turn the virtual switch OFF after X minutes
  3. Use Smart Lights again to turn ON the real switch when the virtual switch turns OFF
  4. Trigger the sequence by saying “Alexa, turn off the lights” (or whatever the real switch is called) and it will turn back on automatically.

Note: the difference between these two answers is that JDRoberts uses a trigger to directly affect the virtual switch, which requires an ON command. This method links the ON --> OFF transition to the virtual switch so the trigger becomes an OFF command, which seems more natural to me.

1 Like

I know this is an old thread, but I came across the need to resolve a similar situation. For those that might be still looking for a solution to this that doesn’t require virtual switches or WebCore, here’s a quick flip of the Power Allowance app that, instead of waiting X minutes to turn a device Off, waits X minutes to turn it back on.

/**
 *  Turn Back On
 *
 *  Turn a switch back on after some time.
 */
 
definition(
    name: "Turn Back On",
	namespace: "smartthings",
	author: "SmartThings",
    description: "Turn a switch back on after some time",
    category: "My Apps",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png"
) 

preferences {
	section("When a switch turns off...") {
		input "theSwitch", "capability.switch"
	}
	section("Turn it back on how many minutes later?") {
		input "minutesLater", "number", title: "When?"
	}
}

def installed() {
	log.debug "Installed with settings: ${settings}"
	subscribe(theSwitch, "switch.off", switchOffHandler, [filterEvents: false])
}

def updated() {
	log.debug "Updated with settings: ${settings}"

	unsubscribe()
	subscribe(theSwitch, "switch.off", switchOffHandler, [filterEvents: false])
}

def switchOffHandler(evt) {
	log.debug "Switch ${theSwitch} turned: ${evt.value}"
	def delay = minutesLater * 60
	log.debug "Turning on in ${minutesLater} minutes (${delay} seconds)"
	runIn(delay, turnOnSwitch)
}

def turnOnSwitch() {
	theSwitch.on()
}
1 Like

I’ve also done this with Alexa… since I like using the voice control in my system more than the automations… I built into EchoSistant that you can say this…

Alexa, turn on the fan for xx minutes in the bedroom. (xx minutes = any number of minutes you choose, you can also say xx hours and xx minutes)
or…
Alexa, turn off the fan for xx minutes in the bedroom.

Either way it performs the command and after the desired time it will reset the switch.

You can also say, Alexa, turn on/off the switch in xx minutes… it will delay for the desired time and then perform the commanded actions.

1 Like

Very nice! Mine was for a specific device that I always wanted off for 30 minutes, so I didn’t want to have to have add any extra “for xx hours”. This has the added advantage that it works with physical switches (you can turn a switch off and it will turn itself back on).

Yes, that’s what I love about SmartThings. Our ability to tailor our homes to be exactly what we want. Mine works with any kind of switch that Alexa can detect in SmartThings, virtual or real.

I sleep with fans on in the bedroom, so I’ll go to take a nap, which never at the same time or for the same amount of time. If I want to get up at a specific time, I can tell Alexa to turn off the fans at xx time. Or if I want to sleep for 45 minutes, I’ll tell her to set an alarm for 45 minutes and to turn off the fans in 43 minutes…

So many options… choice is fantastic, especially when each family member uses it in different ways.

2 Likes

100% agree! EchoSistant looks awesome. I’ll have to play around with it when I have some free time.

2 Likes