SmartThings Community

Turn off after some minutes

smartapp_lighting

(Keithsobo ) #6

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.


(Bruce) #7

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:


(Tom) #8

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.


(Bruce) #9

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…


(Bruce) #10

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.


(Tom) #11

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.


(Bruce) #12

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.


(DavidK) #13

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.


(Bruce) #14

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


(Bruce) #15

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:


(Bruce) #16

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.


(Patrick Musselman) #17

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.


(Quin) #18

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.


(Colin) #19

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


(Quin) #20

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…


(Colin) #21

so you got it into your IDE… did you go into the ST app and add it to your App? If not, you need to go to the Marketplace, click the SmartApps tab, and then scroll down to My SmartApps and install your newly created Smart App. If you already did that, you’ll find the SmartApp in the Smart Apps tab of your ‘things’ view.


(Quin) #22

Yes I found the app. It is set to run. I’m just confused on the trigger. Will it turn the device on after so many min any time it’s turned off? Or do I have to manually trigger it? I can’t see how I would do that.


(Colin) #23

ah ha. Yeah this probably is not the best solution for your use case. Check out Rule Machine smart app instead. You can configure that to turn x device on (or off) after Y minutes.


(Ctwomey) #24

Bruce, first off thanks for writing this app! I was hoping it would be useful to use for my hot water recirculation pump in my house:

I’m trying to limit the times it’s used, not to waste energy. I already have it configured to turn on for a couple of hours in the morning and evening to cover peak shower and kitchen times, but for the rest of the time I’d like to manually activate the pump as-needed and have it turn off after 10 minutes (because the pipes are all hot by then). So I installed your app thinking it would solve this problem, but alas I think it will also turn off my scheduled activations prematurely. Any ideas what to do here?


#25

Bruce is no longer active on this forum. But you should be able to get the results you want with core, so ask in their peer assistance thread. :sunglasses: