Jump to content
C4 Forums | Control4

How to program a light to only stay on for a set time period


Brad_The_Lucky

Recommended Posts

I would like to place my garage lights on a timer so that they are never left on for more than 20 minutes. It would also be nice to have the programming allow for a double click to cancel the timer and leave the light on permanently. Any suggestions on the best way to program this or would it be much easier for me to just wait until 1.6 is released?

I think in the interim I will have some of the LED's elsewhere in the house turn red so that I know the garage lights were left on.

Link to comment
Share on other sites


I like just turning them on to 100%, and then setting them to ramp down over 10 (or in your case, 20) minutes when the garage door opens at night.

That way, it *gradually* gets down to 0, you know it's happening, and they don't stay on for longer than 10 minutes.

Of course, if I tap the bottom button to turn them off, or tap the top button to turn them all the way on, the ramp is over.

RyanE

Link to comment
Share on other sites

I like just turning them on to 100%, and then setting them to ramp down over 10 (or in your case, 20) minutes when the garage door opens at night.

That way, it *gradually* gets down to 0, you know it's happening, and they don't stay on for longer than 10 minutes.

Of course, if I tap the bottom button to turn them off, or tap the top button to turn them all the way on, the ramp is over.

RyanE

Ryan-

Neat idea. I get how tapping the bottom would turn them off and end the ramp, but how would tapping the top not just put them back to 100% with the ramp beginning again. I'm assuming that the initial ramp would be programmed as an event for "When light turns on" or "when top button is tapped" and thus tapping the top again would just start the cycle over.

I can certainly think of ways to do this . . . i.e. when light comes on, check variable "RampState". If "off" then set variable to "on" and start ramp. If "on" then set variable to "off" and no ramp. Then program for when the light goes off it should set the RampState variable to off. Is there a cleaner way of doing this that I'm overlooking?

-Jason

Link to comment
Share on other sites

I would like to place my garage lights on a timer so that they are never left on for more than 20 minutes. It would also be nice to have the programming allow for a double click to cancel the timer and leave the light on permanently. Any suggestions on the best way to program this or would it be much easier for me to just wait until 1.6 is released?

A couple ways you might do this come to mind . . . my preferred means would be as follows:

The complexity comes from the fact (discussed elsewhere) that you can't interrupt a countdown. Once it's happening there's nothing you can do to stop it, so no matter what else you do a regular countdown would still turn the light off in 20 minutes.

Variables are one solution. Create a variable called "GarageCountdown" or something like that. When the garage light gets turned on, you set that variable to 20. If you have access to a dealer who can program you a loop, you could then use a loop to check that variable (i.e. While light is on, if variable "GarageCountdown" is greater than 0, wait 60 seconds and set variable to variable -1. If variable is 0, turn off light). If you don't have access to a loop, I wrote http://www.c4forums.com/viewtopic.php?pid=10301#p10301 (with you, Brad) about how you could (I think) use two variables to bounce control back and forth and recreate the effect of a loop. In this case, you would program the light to set the variable to 20. You would program the GarageCountdown variable, when it changes, to wait 10 seconds and then toggle another variable (call it MinuteDelay). In the programming for MinuteDelay, you would program that when it changes it waits 50 seconds, then decrements GarageCountdown. GarageCountdown, in turn, when it changes, checks to see if it's now zero. If it is it turns the light off, if it's not it waits 10 and changes MinuteDelay, etc etc. In this way you create a loop without being able to program a loop.

Now, as to your override, you could use another tap to set the GarageCountdown variable to a very large number (say the longest you'd ever want to leave it on) and just let it keep decrementing. If you wanted to reduce the execution overhead (i.e. not have the unnecessary decrementing going on for an hour or two while you're working in the garage) then you could add some programming to the GarageCountdown that says if it equals 100, then Stop (i.e. don't trigger the MinuteDelay loop). Now you have your second tap set GarageCountdown to 100 and it ends there.

For that second tap, I'd suggest either "When top button is pushed and light is on" set to 100 and/or "when bottom button is pushed and light is off". I wrote about this here: http://www.c4forums.com/viewtopic.php?id=1319 and it's something I've found very useful. As applied to your situation, it would mean you could basically walk up to the switch when the light is off, tap the bottom to come on and stay on, or tap the top to come on and countdown. If, sometime later, you realize you want the light to stay on, you would just tap the top again to set the countdown to 100 and it would stay on.

If any of this is unclear, let me know and I'll try and do a better job explaining it . . .

--Jason

Link to comment
Share on other sites

Jason,

The ramp is implemented as a command to the dimmer. Once that ramp command is sent to the dimmer, the dimmer does the ramping over time, with no new input from the controller.

The ramp command works so that if a light is doing a ramp command, if you press either 'on' or 'off' or hold the top or bottom button, it ends the ramp command.

The ramp stops when you decide you're going to set the value of the light.

RyanE

Link to comment
Share on other sites

Jason,

The ramp is implemented as a command to the dimmer. Once that ramp command is sent to the dimmer, the dimmer does the ramping over time, with no new input from the controller.

The ramp command works so that if a light is doing a ramp command, if you press either 'on' or 'off' or hold the top or bottom button, it ends the ramp command.

The ramp stops when you decide you're going to set the value of the light.

RyanE

So this solution would require turning the light on from something other than the normal "top = on" command from the switch. i.e. either using a 6-button or other controller or else using something like the bottom press when off if you want to turn on and trigger a ramp. Just because you'd need it to be different from whatever you would subsequently do to cause the light to stay on, right?

--Jason

Link to comment
Share on other sites

Yes, my garage door turns on the garage lights, and then causes them to ramp, I suppose you could probably program it so that every time you turned them on, they would ramp to 0 over 10 minutes.

You could just put it in the 'when top button pressed' event, put in a delay to let the light get to wherever you wanted, then put in code to 'ramp to 0 over 10 minutes'.

I haven't tried that, but I would think it should work.

RyanE

Link to comment
Share on other sites

OK, it does work, but it makes more sense to program it on the 'Top Button Released' event.

I put in the following in the 'Top Button Released' event:

delay 1 second

Ramp to Level 0 on Room->Light over 5 seconds

It works fine. As soon as I release the button, it starts ramping down.

I put in the 1 second delay so when you tap the button, it gets all the way on before starting the ramp down. Otherwise, it doesn't ramp to 100% when you tap the top, because the light is still coming on.

Cool idea... Auto-off lights are pretty easy that way.

RyanE

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...