Turn off after some minutes

EDITED: ST has fixed the omission in Smart Lights, and this function is now there. When creating an automation to do this, select your light, turn off, and then scroll to the very bottom of the list of how to trigger it to Power Allowance Exceeded (which is a ridiculous name, but oh well).

Smart Lights is missing the function that was available in Lights & Switches V1, to turn off some switches x minutes after they were turned on. I’m sure ST will fix this omission soon. In the meantime, this app will do that function:

4 Likes

And just to clarify for those who haven’t been following this issue…

Smart lights does have an option to turn off a light that was turned on with motion.

I believe the purpose of the code that @bravenel is providing to the community is to turn a light off after some minutes without requiring an additional sensor to be involved. Just when the light gets turned on it stays on for that period of time and then turns off again. :sunglasses:

@bravenel. Thank you for doing this. Not sure what ST was thinking on this but I am sure they will get it fixed soon. But in the meantime your app is proving to be very helpful!

1 Like

Thanks,

Anyway you can add only during an optional time of day? The reason I want to use this for my outside lights. Kids have tendancy to turn on all lights on a panel. So if from 9am till 6pm turn off light if turned after 10 minutes. If outside of that time. Just leave them on.

HaHa, sure. Before long you guys are going to have me rewrite Smart Lights…

Here is the modified version of this little app that allows you to restrict turning off the lights after x minutes to time of day, days of week, or mode.

2 Likes

Thanks! With 6 six kids, using home automation like this saves me a lot of energy usage. Also, the headache of coming home and knowing the outside lights where left on all day.

1 Like

I have some house guests at the moment, and it reminds me that one of the reasons I went down the path of motion controlled lighting was that certain people always left lights on. Not any more! HaHa :grinning:

1 Like

Bruce this is great. Any way you could add sunset and sunrise as time of day options? I’m looking to turn my front garage lights on for several minutes after the garage opens at night time.

If you have modes tied to sunrise and sunset, you could just use a mode restriction. That’s how I do it. This is really what modes are good for. I’ll look at the code…

HaHa, Even Smart Lights doesn’t give you this option (using sunrise / sunset time restriction), unless you use a mode restriction. So that’s the way to go. Have a mode that is automatically changed to at sunset (another at sunrise). Then create a Smart Lights instance that turns on the light when the door opens, mode restricted to your Night mode. Add the app above, with or without the mode restriction, to turn it off x minutes later.

Bruce, thanks for taking a look. I just started with Smarthings this weekend. It has a lot of great features that I’ve been exploring. I have been using(going to set up as secondary now) another smart home system that was just a little easier to program. You could easily add as many conditionals(time, device status, etc) as you wanted to a scene. I feel like it should be simpler to just tell smarthtings to turn a light on when the garage opens for 10 minutes but only at night. Just do things like that no matter what mode I’m in. It’s just a different way of thinking.

Again, what you’ve provided is very helpful.

Yes, SmartThings does have a different model. Modes are used to do this sort of test. There really isn’t a concept of “night”, per se, although you can create that with a mode. My guess is that you aren’t using modes at all yet. Nor is there a concept of adding conditionals to a scene, as there aren’t really “scenes” in Smart Things, per se. One can have as many conditions as one wants for lighting automations – but there isn’t a condition of “after sunset”.

Smart Lights, and other apps and Routines, do allow you to use sunrise and sunset as time triggers (e.g., turn on at sunset), with offsets from sunrise and sunset. And, one can trigger a mode change with sunrise and sunset using a Routine.

First let me thank Bruce for his work to help the community.

But I have a clarification.

bruce wrote:
HaHa, Even Smart Lights doesn’t give you this option (using sunrise / sunset time restriction), unless you use a mode restriction.

I think this is not true. If you go in, the option is specific time OR sunset OR sunrise.

I have some light actions that are either only during the day or only during the night.

I stand corrected. I guess I’ll have to add that to the restrictions in the little app.

I have added these options, so now it basically has the same functionality it would have if ST had put it in Smart Lights.

You can restrict the app to only turn off after some minutes based on time of day (including sunrise and sunset with offsets), days of week, and mode.

The updated code is in Github:

1 Like

The omission in Smart Lights has been corrected, and you no longer need this app to get that functionality.

When creating a Smart Lights automation to do this, select your light, turn off, and then scroll to the very bottom of the list of how to trigger it to Power Allowance Exceeded.

1 Like

Is it possible to add a condition to this app that could check if Smart Monitor is in an intruder position and not function, like bypassing the turn off commands, and if not function as normal? Use case is this. I have several Foscam cameras that are armed when the mode is set to away. If the Smart Home Monitor is tripped I would like the Foscam camera to stay in an armed state or on when the mode changes to Home-XX. Meaning that I will have the physical turn them off in the app. If not I would like the app to turn off the cameras as a safe guard against a failed off command sent to the camera on the mode change. I am doing this now and it is working. I only want ST to get a snapshot of my doors or windows or glass break is tripped when in Home-XX mode. It has been happening often and I want to subdue the camera’s sound alarms to settle down the fam. :smile: Plus the annoying flood of false alarm native foscam emails.

I am sure this is an ignorant question. Thanks for the code for the turn lights off after some minutes app. For those of us who don’t know how, how does one get that code into my smart things app? I Sometimes need to turn the outlet off to my dog door to keep them inside. But if I forget to turn it back on…bad. I want it to turn on 2 hours after its turned off.

Custom SmartApps are installed in the developer portal or IDE. Here’s a Youtube video that should help:

Thanks, I have figured out how to add the smart app, and I have done so successfully. I even edited the code to make it hopefully turn things on after some minutes… (by changing the word off to on where it appears in the code). Now my question is, what triggers this. How do i start that timer, or what starts that timer. I want it to turn a device on after 120 minutes…