Jump to content

Timed Night Light


sfhutchi

Recommended Posts

For many rooms, I added a simple program that would turn the light on at a very low level by pressing 'Off' on the paddle. It was simply a way to quickly walk into a room at night and avoid standing there for a few seconds to dim up the light or press 'On' and blind myself or the occupants.

 

This has worked fine, but now I decided to add a built in delay and then shut-off. Unfortunately, the program goes false immediately after initiating the program and aborts before the delay is completed. Do I have to use 2 programs to do this?

 

If
       Status  'Master Bedroom Light' is Off
   And Control 'Master Bedroom Light' is switched Off

Then
       Set 'Master Bedroom Light' 20%
       Wait  20 seconds
       Set 'Master Bedroom Light' Off

Else
  - No Actions - (To add one, press 'Action')


Link to comment

Don't forget, there is on, then there is fast on (double tap). If you simply set the on level to 20%, a single tap gets the reduced level and a double tap gets a full level. This might also prove more intuitive for visitors, spouses, kids, etc....

 

If you go that route, then you could create a single program

 

If

Control 'Master Bedroom Light' is switched on

 

Then

Wait 20 seconds

set 'Master Bedroom Light' Off

 

Else

No Actions - (To add one, press 'Action')

 

If you want to continue to use an off tap as an on command, this may take two programs, but I have not thought much about it.

Link to comment

One program can do it. The first command in the THEN causes the IF to be false and so program runs ELSE. So:

 

If status of LIGHTS is off

And control of LIGHTS is switched off

 

Then set LIGHTS 20%

 

Else wait 30 seconds

Set LIGHTS off

 

 

Thanks for the idea. I've implemented it in a few rooms.

Link to comment
Don't forget, there is on, then there is fast on (double tap). If you simply set the on level to 20%, a single tap gets the reduced level and a double tap gets a full level. This might also prove more intuitive for visitors, spouses, kids, etc....

 

I have at least one room where I have the set level at less than 100%, and I think that I have only succeeded in training my wife to use a double-tap every time so that she can get all the light possible instantly. I guess she didn't like my smooth ramp-up. Maybe I need a program run on double-tap that then slowly ramps the light back down to the lower setup. :)

Link to comment

Nice!

 

One program can do it. The first command in the THEN causes the IF to be false and so program runs ELSE. So:

 

If status of LIGHTS is off

And control of LIGHTS is switched off

 

Then set LIGHTS 20%

 

Else wait 30 seconds

Set LIGHTS off

 

 

Thanks for the idea. I've implemented it in a few rooms.

Link to comment
One program can do it. The first command in the THEN causes the IF to be false and so program runs ELSE. So:

 

If status of LIGHTS is off

And control of LIGHTS is switched off

 

Then set LIGHTS 20%

 

Else wait 30 seconds

Set LIGHTS off

 

 

Thanks for the idea. I've implemented it in a few rooms.

 

Works like a champ...Thanks!..... and is one simple program. So just to be sure that I follow the logic.. the then runs when the 'IF' is true... so THEN runs immediately making the IF false, so ELSE kicks in?

Link to comment

Rand,

 

What do you think about starting to add some of these tested ideas to the Wiki. I noticed that the section on 'How To Guide' could use a lot more examples. I know that this would be helpful for anyone starting out.

 

I am not sure about what the best structure is to organize this... but we could have examples grouped by different topics:

- Using Motion Sensors to Control Room Lighting

- Bathroom Lighting and Fan Control

- Night Time Scenes

- Away from Home Programs

- etc...

 

I can see how this can become fairly disorganized, so maybe if we can put together a basic structure to start with and then gather a lot of what each of us are using.. and start putting it in there. Much is in the forum today, but not easy to find. Another option is to have people start posting their examples to a thread and have one or two people volunteer to start pulling them out of there and putting them in the wiki.

 

There have got to be hundreds of examples out there today.

Link to comment
One program can do it. The first command in the THEN causes the IF to be false and so program runs ELSE. So:

 

If status of LIGHTS is off

And control of LIGHTS is switched off

 

Then set LIGHTS 20%

 

Else wait 30 seconds

Set LIGHTS off

 

Nice x 2! I like it.

Link to comment
I guess thats why I'm not a programmer. When that switch is turned on from the off position the program runs and turns the light out in 20 seconds. Rand has it right, i.e. 2 programs. Oops.

 

Your suggestion works well with one program.

 

If
       Status  'Master Bedroom Light' is Off
   And Control 'Master Bedroom Light' is switched Off

Then
       Set 'Master Bedroom Light' 20%

Else
       Wait  5 seconds
       Set Scene 'Slow Master Bedroom Light' Off

 

Is this not working for you?

Link to comment
Turn the light on. It will go off in the delay time.

It's very useful to understand why this is the case, and how these "little" logic issues can come back to bite you when it seems all should work as expected.

 

The example program turns out to be more complex than initially apparent. Let's walk through the the logic:

 

If
       Status  'Master Bedroom Light' is Off
   And Control 'Master Bedroom Light' is switched Off

Then
       Set 'Master Bedroom Light' 20%

Else
       Wait  5 seconds
       Set Scene 'Slow Master Bedroom Light' Off

It works fine for the intended situation; that is, if the light is already off and the control is turned off, the IF is true and the THEN executes, turning the light on to 20%. This causes a status change, which causes the IF to be evaluated again. Since the status has changed and is no longer OFF, the IF is false and the ELSE executes: delay 5 seconds, followed by triggering the scene which results in light being off. Note that the status of the light changes yet again (to OFF), causing the IF to be evaluated one more time. The IF is FALSE (doesn't matter what the light status is; the Control was not activated, so it is FALSE) and the ELSE executes again. The program waits another 5 seconds and turns off the light again (no net effect this time since it's already off, but there is insteon traffic). The program finally stops.

 

The unintended effects happen when the light is off and is turned on. The light turns on, which causes a status change from OFF to ON. Which causes the IF of this program to be evaluated. The IF evaluates to FALSE due to the Status clause. Which means the ELSE executes. The program waits, and then turns the light back off via the Scene command. Not what you want.

 

Moral: if you have anything in a program's ELSE, you must be extra careful about unintended effects due to logic inherent in how the IF is constructed.

 

--Mark

Link to comment

 

Moral: if you have anything in a program's ELSE, you must be extra careful about unintended effects due to logic inherent in how the IF is constructed.

 

--Mark

 

Good lesson. I have almost no other situations where I use 'Else' so I will probably stay away from it for now. :)

 

Here is what I have put together that seems to work as intended.

 

If
       Status  'Room Light' is Off
   And Control 'Room Light' is switched Off

Then
       Set 'Room Light' Query
       Run Program 'Light Dim Off' (Then Path)
       Set 'Room Light' 30%

Else
  - No Actions - (To add one, press 'Action')

 

*I added the Query because during testing, there were a few times that the ISY didn't seem to have the appropriate status of the light. This was likely due to my continued playing at the switch. I will probably take this out later.

 

I used this program to call the 'timed' off before the 'If' statement goes false. I call the 'Then' directly so this program has no conditions.

 

Light Dim Off

If
  - No Conditions - (To add one, press 'Schedule' or 'Condition')

Then
       Wait  5 seconds
       Set 'Room Light' Off

Else
  - No Actions - (To add one, press 'Action')

 

So if all works as intended this time, pressing 'Off' when the light is off should give me a short-lived dimmed night light. Outside of this the light should function as normal. I will likely change the 'Room Light' Off to a slow ramped scene to make it a more elegant fade out.

Link to comment
Here is what I have put together that seems to work as intended. ... Outside of this the light should function as normal.

A workable solution! But there is another gotcha which you may care about.

 

Consider this situation: the nightlight sequence has been activated (light at 30%) and program 'Light Dim Off ' is running its wait, counting down to turning the light off. During this interval, someone changes their mind and turns the light on with the switch. The light goes on, but the running program is unaffected. When the wait completes, the program will turn off the light as previously initiated, leaving a surprised person in the dark.

 

There is probably a more elegant solution, but a quick fix with your existing two programs is to add a third:

 

If
       Control 'Room Light' is switched On
Then
       Stop Program 'Light Dim Off'
Else
   - No Actions -

 

--Mark

Link to comment

A workable solution! But there is another gotcha which you may care about.

 

Consider this situation: the nightlight sequence has been activated (light at 30%) and program 'Light Dim Off ' is running its wait, counting down to turning the light off. During this interval, someone changes their mind and turns the light on with the switch. The light goes on, but the running program is unaffected. When the wait completes, the program will turn off the light as previously initiated, leaving a surprised person in the dark.

 

I have updated the second program and surprisingly it seems to work.

 

Just to refresh, the first program initiates the 'Night Light'.. but before the If conditions go false by the light turning on to a dim level, I call a second program that initiates a 'timed off'.

 

If
       Status  'Room Light' is Off
   And Control 'Room Light' is switched Off

Then
       Run Program 'Light Dim Off' (Then Path)
       Set 'Room Light' 25%

Else
  - No Actions - (To add one, press 'Action')

 

In the second program, instead of adding a Wait, and then turning the light off, I made a scene that slowly dims the light over a few minutes. It gives a good effect. Light turns on very dim... and slowly decays to off.

 

If
  - No Conditions - (To add one, press 'Schedule' or 'Condition')

Then
       Set Scene 'Slow Room Light' Off

Else
  - No Actions - (To add one, press 'Action')

 

 

The interesting part is that technically I am turning the light off before I set the light directly to 25%. It seems very repeatable though. The light has always come on first to 25%, and then the slow decay starts.

 

I only tried this as a long shot to avoid 3 programs for this effect, but it seems repeatable. Anyone have a good technical reason why?

Link to comment

Why not just combine everything given in the original one-program else into the then?

 

If 
       Status  'Master Bedroom Light' is Off 
   And Control 'Master Bedroom Light' is switched Off 

Then 
       Set 'Master Bedroom Light' 20% 
       Wait XX seconds 
       Set Scene 'Slow Master Bedroom Light' Off

Else 

Link to comment

This was my first attempt. The problem is that the IF condition of 'Master Bedroom Light' goes false and the program aborts as soon as the first THEN (Set Master Bedroom Light to 20%) initiates.

 

This is why I then broke it into two programs... but as I found out, this then caused some other problems. It seems that the fool-proof solution is 3 programs as another poster recommended, but I am just playing around trying to find a simpler way if possible.

Link to comment
  • 1 month later...
Why not just combine everything given in the original one-program else into the then?

 

If 
       Status  'Master Bedroom Light' is Off 
   And Control 'Master Bedroom Light' is switched Off 

Then 
       Set 'Master Bedroom Light' 20% 
       Wait XX seconds 
       Set Scene 'Slow Master Bedroom Light' Off

Else 

 

sfhutchi, in io_guy's program, simply remove the Wait line. The program will then be equivalent to what you now have, but in a single program.

 

The If will be re-evaluated due to the change in the light status. But, both remaining lines in the Then will execute before it is re-evaluated, because they are an autonomous unit. It is the Wait (or Repeat) command which causes re-evaluation prior to completion of a Then or Else clause.

Link to comment
Rand,

 

What do you think about starting to add some of these tested ideas to the Wiki. I noticed that the section on 'How To Guide' could use a lot more examples. I know that this would be helpful for anyone starting out.

 

I am not sure about what the best structure is to organize this... but we could have examples grouped by different topics:

- Using Motion Sensors to Control Room Lighting

- Bathroom Lighting and Fan Control

- Night Time Scenes

- Away from Home Programs

- etc...

 

I can see how this can become fairly disorganized, so maybe if we can put together a basic structure to start with and then gather a lot of what each of us are using.. and start putting it in there. Much is in the forum today, but not easy to find. Another option is to have people start posting their examples to a thread and have one or two people volunteer to start pulling them out of there and putting them in the wiki.

 

There have got to be hundreds of examples out there today.

sfhutchi, this is an excellent idea, and thanks for suggesting it. The only reason it has not already been done, is because our resources are so very limited.

 

Everyone remember, however, that our wiki is actually a user-to-user resource, so anyone with a little time, who is so inclined, please do feel free to add examples to the wiki as you implement them, or as you come across them in the forums.

 

The structure outlined above seems like a very good starting point, and of course additional suggestions are always welcome.

Link to comment

Archived

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


  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

    • There are no registered users currently online
  • Forum Statistics

    • Total Topics
      36.9k
    • Total Posts
      370.2k
×
×
  • Create New...