best way to automatically turn off a light after a set period of time (30 min?)

Hi everyone!
I was a bit inspired by reading a previous post by sebby (http://forum.micasaverde.com/index.php/topic,119190.0.html), and been playing around with a bit of the functionality rigpapa demonstrates with counting >n devices being on. Not sure I’m going about this the best way so wanted to get some thoughts from the experts.

So I have 3 lights I’d like to have automatically turn off if they’re left on for more than 30 mins. For simplicity let’s call them device 1, 2 & 3.

I was examining rigpaps custom expression to check the number of devices that are on, as such:

I defined a new service variable “NumDevicesOn” and used this:

len( iterate( list(1,2,3), ‘if( getstate( dev, “urn:upnp-org:serviceId:SwitchPower1”, “Status” )==“1”, 1, null )’, “dev” ) )

This works… but the problem is what do I execute if NumDevicesOn is >0? (and using the sustained for for 1800 sec / 30 min)

I could execute a trip action that turns off device 1,2 & 3, that’s easy…

But if device 1 has been on for 30 mins and device 2 has only been on for 5 mintues, I don’t really want device 2 to be turned off yet… Just device 1. hmm… :-\

Do I have to build a separate reactor sensor for each light? Checking the status of each and if they’ve been sustained for 30 min, then execute a trip action to turn off each individual light?

I could use delay light as well, as it has a feature to turn off after a set period on manual activation, but same issue… I can set each light as a trigger, but I can only run 1 scene to turn off ALL devices from a single delay light sensor… otherwise, I’m creating separate delaylight sensors for each light.

Is there a way to do this all with 1 reactor sensor, using the expression code above that monitors all the lights I’d want to have 30 the minute auto-off cycles assigned to? and selectively executes a “turn off” only for the light that’s been on for 30 min? ???

This is an example where DelayLight might be the better tool for one simple reason: it is part of DelayLight’s intrinsic behavior that when any of its controlled lights are turned on or off, as long as at least one light remains on, the timer is restarted, so the timing extends accordingly. I’ve been chided (playfully) before for repeating the old saying: “to the man holding a hammer, all things look like a nail.” Sometimes, there are just better tools for a job–not necessarily more powerful or complicated tools; sometimes the simplicity of another tool is its strength.

Ha Ha yes I agree with the hammer and everything looking like a nail philosophy!! Exactly why I was thinking I better seek a 2nd opinion before I take a hammer to a screw lol!!

I think I follow you… I didn’t realize Delaylight worked in this fashion.

So, let me see if I’ve got this straight…

I can use a single delaylight sensor, using each of my 3 devices as “on devices”

Then, happily set a scene that turns off all 3 devices, and the worst thing that would happen is that if someone turned on device #1, and then 20 mins later device #2 was turned on, the timer would reset.

So If I had 30 mins set as my timer device #2 would run for 30 mins as intended, and device #1 would run for 20 + 30 = 50 mins.

(which is still a lot better than the basement lights staying on all night cause the kids didn’t turn them off lol!)

is that correct?

[quote=“connormacleod, post:3, topic:200483”]Ha Ha yes I agree with the hammer and everything looking like a nail philosophy!! Exactly why I was thinking I better seek a 2nd opinion before I take a hammer to a screw lol!!

I think I follow you… I didn’t realize Delaylight worked in this fashion.

So, let me see if I’ve got this straight…

I can use a single delaylight sensor, using each of my 3 devices as triggers…

Then, happily set a scene that turns off all 3 devices, and the worst thing that would happen is that if someone turned on device #1, and then 20 mins later device #2 was turned on, the timer would reset.

So If I had 30 mins set as my timer device #2 would run for 30 mins as intended, and device #1 would run for 20 + 30 = 50 mins.

(which is still a lot better than the basement lights staying on all night cause the kids didn’t turn them off lol!)

is that correct?[/quote]

Correct, but a couple of details…

Don’t think of your lights as “triggers” for DelayLight. In DelayLight’s language, “triggers” are sensor devices (like door switches or motion sensors) that initiate an automatic turn-on of lights (hands-free, so to speak), and have a separate delay period (referred to as the “automatic” delay, because it turns on the lights automatically in response). You didn’t mention any sensors like that, so I’m assuming there are none in your configuration. In this case, DelayLight’s “trigger” configuration will be empty. But you will configure your three light switches/dimmers on the “off” list in DelayLight (they don’t need to be on the “on” list), and by doing so, DelayLight will watch these devices, and start timing using the “manual” delay if one of the lights is turned on. And as I described, the timing period is extended when another light is turned on, etc. (your timing estimates are correct).

And no scenes are required. DelayLight controls the lights directly. You can use a scene if you want, but it’s not necessary.

So, just list the three devices on the DelayLight Timer’s “off” list (only), and Bob’s your uncle. Other than setting the (manual mode) time delay period you want, that’s all it needs to work the way you are asking, right out of the box.

[quote=“rigpapa, post:4, topic:200483”]Don’t think of your lights as “triggers” for DelayLight. In DelayLight’s language, “triggers” are sensor devices (like door switches or motion sensors) that initiate an automatic turn-on of lights (hands-free, so to speak), and have a separate delay period (referred to as the “automatic” delay, because it turns on the lights automatically in response). You didn’t mention any sensors like that, so I’m assuming there are none in your configuration. In this case, DelayLight’s “trigger” configuration will be empty. But you will configure your three light switches/dimmers on the “off” list in DelayLight (they don’t need to be on the “on” list), and by doing so, DelayLight will watch these devices, and start timing using the “manual” delay if one of the lights is turned on. And as I described, the timing period is extended when another light is turned on, etc. (your timing estimates are correct).

And no scenes are required. DelayLight controls the lights directly. You can use a scene if you want, but it’s not necessary.

So, just list the three devices on the DelayLight Timer’s “off” list (only), and Bob’s your uncle. Other than setting the (manual mode) time delay period you want, that’s all it needs to work the way you are asking, right out of the box.[/quote]

Oh wow, OK, I appreciate the clarification. Yes in this instance I don’t have any sensor devices to automatically control these lights (though that could change in the future), just the manual mode for now. :slight_smile:

I didn’t realize I could get away without having to specify them in “on devices” when using the “manual off delay” timer mode exclusively, but I guess that kinda makes sense. Good to know delaylight will monitor the devices listed in the “off” list and use the "manual off delay"set time for those without having to explicitly set them in the “on list”.

This greatly simplifies my setup. (until I decide to complicate it with “trigger” sensors that later on !), but now I understand how I could easily add those into the same delaylight control in the future as triggers that will use the “automatic off delay” Gonna go set this up! Thanks Patrick!