Jump to content

How to turn off a light after amount of time?


barkster

Recommended Posts

Posted

I want to turn off a light after say 10 mins of it coming on.  When they turn on it starts some type of timer and then after it turns off it can be turned on again and repeat. What's the best way to do it?

Posted (edited)

To add to oberkc's excelent reply, depending on what causes the lights to turn on, you may consider using Status instead of Control in the if statement.  When using control, this program will only trigger when the switch in manually operated and, in this case, only when turned on specifically rather than fast on or fade up.  Status will catch the change in status regardless of how it gets that way - even if the switch is turned on remotely by a linked device or scene.

If
   Status 'Switch' is not off

Then
   Wait 10 minutes
   Set Switch Off

Else

Understanding the difference between Status and Control program triggers will allow you much greater capabilities and flexibility with ISY programming.

 

Hope this helps.

 

-Xathros

Edited by Xathros
Posted

Awesome, that answered two questions in one because I was writing something the other day and wondered why it wasn't working when I was using control  Thanks!

Posted (edited)

Barkster,

 

Using "Status device is not off" is the best approach if you want a simple timer.

 

I took a more sophisticated but also more complex route that I can share.

 

My requirements were:

1 - Shutdown lights gradually, so that if the room is occupied, this leaves a chance to turn it on again before being in complete darkness.

2 - Provide a way to give more time, if you know you will occupy the room longer than usual (example receiving friends late). The approach here is that a Double Click (FastOn) will provide me 1 or 2 hours, instead of just a few minutes.

 

This unfortunately requires 4-5 programs and a variable, for each of your lights. The complex part is that you want to trap the "Status is not off" independantly of the "Fast On"... which will also trigger a status change. And during the shutdown, dimming the light will also trigger a status change, which you don't want either. That's the reason for the variable.

 

This is how I did it.

 

Program 1: StatusOn DeviceXYZ

If
        (
             Status  'RC / Cuisine' is not Off
          Or Control 'RC / Cuisine' is switched On
        )
    And $TimerStateCuisine is 0
 
Then
        Stop program 'OffTimer - Cuisine - Shutdown'
        Wait  30 minutes
        Run Program 'OffTimer - Cuisine - Shutdown' (If)
 
Else
   - No Actions - (To add one, press 'Action')

$TimerStateCuisine is an integer variable.
0 = Normal operation
1 = FastOn timer or Shutdown in progress (Bypass status detection)

The Status "is not off" is useful to catch all cases of having the light turned on no matter how.
The Control "is switched on" is useful for the case where the light is already On. This will restart the timer.

 

 

Program 2: Shutdown DeviceXYZ

If
        Status  'RC / Cuisine' > 50%
 
Then
        $TimerStateCuisine  = 1
        Set 'RC / Cuisine' 50%
        Wait  1 second
        $TimerStateCuisine  = 0
        Wait  1 minute
        Run Program 'OffTimer - Cuisine - Shutdown' (Else Path)
 
Else
        $TimerStateCuisine  = 1
        Set 'RC / Cuisine' 25%
        Wait  1 second
        $TimerStateCuisine  = 0
        Wait  1 minute
        Set 'RC / Cuisine' Off

This program is always disabled. This means a change of status will not trigger the program. The only time the program will run is when it is called by another program.

 

The idea here is that you want the shutdown to start at 50% if the light was 50% or more, but if the light was let's say 30%, you don't want to brighten it to 50%. It will start at 25% in this case.

The 1sec delay after changing the light state is to allow reevaluation of the Program 1 (StatusOn program)
Without it, the TimerStatus would be set to 0 too rapidly, and StatusOn would be reevaluated while the variable is set to 0, allowing
the StatusOn then clause to run, and therefore stopping the shutdown sequence.
 

The shutdown could very well be done using a change to the ramp rate, then just turning it off. I preferred this way.

 

Hint: If the switch is not a dimmer, you can have it beep a few times before turning it off.

 

 

Program 3: FastOn DeviceXYZ

If
        Control 'RC / Cuisine' is switched Fast On
 
Then
        $TimerStateCuisine  = 1
        Stop program 'OffTimer - Cuisine - Shutdown'
        Wait  2 hours
        Run Program 'OffTimer - Cuisine - Shutdown' (If)
 
Else
   - No Actions - (To add one, press 'Action')

When you want more time, the FastOn would you 2 hours, instead of the 30 minutes in the StatusOn program. Setting the variable to 1 will prevent running the Program 1 (StatusOn) then clause.

 

Program 4: StatusOff DeviceXYZ

If
        Status  'RC / Cuisine' is Off
 
Then
        Stop program 'OffTimer - Cuisine - FastOn'
        Stop program 'OffTimer - Cuisine - StatusOn'
        $TimerStateCuisine  = 0
 
Else
   - No Actions - (To add one, press 'Action')

Whenever a device is turned off, no matter how, you want the timers to stop. Otherwise, a shutdown will eventually run... brightening the light to 25% before turning it off again.

 

Program 5: Shutdown at midnight

If
        Time is 12:00:00AM
    And Status  'RC / Cuisine' is not Off
 
Then
        Run Program 'OffTimer - Cuisine - Shutdown' (If)
 
Else
   - No Actions - (To add one, press 'Action')

I normally put all these programs in a folder which is active only between midnight and 4pm, depending on the room. For example, I do not want timers in the kitchen or dining room during the evening. Only after midnight, or day time, should someone turn it on. Therefore a program is required to initiate a shutdown, because if it was left on, no timers will be active and it will stay on all night.

 

I have several variations of these programs. The delays are different depending on the use of the room. You can also enhance it so that the timer is reset if there is motion in the room.

 

Benoit

Edited by bmercier
Guest
This topic is now closed to further replies.

×
×
  • Create New...