Jump to content

Turn off closet light after 10 minutes (using 'Finally')


Chris Jahn

Recommended Posts

Here is an example of how to automatically turn off a Closet light after 10 minutes.

 

Incomplete:

If 
   Control 'Closet' is On 

Then 
   Set 'Closet Light' On 
   Wait 10 minutes 
   Set 'Closet Light' Off 

 

In this scenario, when you press the 'Closet' button to 'On' the trigger starts running the 'Then' actions.

 

When the 'If' condition is no longer true, the 'Then' actions stop running (even if not complete), and the 'Finally' actions start running.

 

So in this case, if after 5 minutes you hit the 'Closet' button 'Off', the 'Then' stops running immediately and the Closet light will not go off at all (even after 10 minutes).

 

The way to fix this is to add a 'Finally' action. When you hit 'Off', the 'Then' stops running, and the 'Finally' starts running, which turns off the light.

 

Correct program:

If 
   Control 'Closet' is On 

Then 
   Set 'Closet Light' On 
   Wait 10 minutes 
   Set 'Closet Light' Off 

Finally 
   Set 'Closet Light' Off 

 

You essentially have 2 ways for the light to turn off:

1) 10 minutes after its turned on

2) When you turn the control off

 

Whenever you turn the 'Closet' button 'On', it restarts the trigger thus if you don't hit the button again, it will wait 10 minutes from that point to turn off the light.

 

Having said that, there is a bug that will be fixed for the next upgrade.

If your button is non-Toggle (i.e. always sends 'On' when you press it), it assumes that nothing has changed and thus will not turn on the light.

 

This obviously severely inhibits non-Toggle buttons, but it will be fixed during this beta period.

Link to comment

Go to the 'Program Summary' Tab

1. Be sure the program is enabled.

2. When you press the On button you should see the program in 'Running' mode.

 

There is a bug that is fixed in the next Beta drop for Non-toggle buttons. For now, if the button you are using is non-toggle, then change it to toggle.

 

There is an existing general problem where in some cases ISY is not updated with events from devices not in a group. To be sure it is getting updated, do the following:

 

1. Add the device to a group

2. Do a 'Restore device' on that device.

 

I set this up and nothing happened after the length of time. Is there something we have to do to activate these programs?
Link to comment

Mark,

Glad to hear they are working for you now.

 

It sounds like the original problem may have been that you forgot to "Save Changes". That would explain why your triggers didn't run in the first place, and why they weren't there when restarted the "Administrative Console".

 

If the arrow on the program Icon in the tree is green, that means the program has changes that have not been saved.

 

Strange, I went out of the "Administrative Console" then came back in and all my new triggers where gone. So I rebuilt the two bathroom timer ones and now they are functioning.
Link to comment

It sounds like the original problem may have been that you forgot to "Save Changes". That would explain why your triggers didn't run in the first place, and why they weren't there when restarted the "Administrative Console".

 

If the arrow on the program Icon in the tree is green, that means the program has changes that have not been saved.

 

This is one of the problems that I had. I did see the button (eventually) but it is not obvious that the programs are not active without 'saving'. They show as enabled in the 'Program Summary' page. Maybe this should be made more obvious or updated on the fly.

Link to comment

Why does this have to be this complicated?

 

If you are using the switch that is the load that you want to time, don't you simply need something like this?

 

If

Control 'Fan' is On

Then

Wait 5 minutes

Set 'Fan' Off

 

 

Shouldn't this allow you to press off to cancel and reset anytime before 5 minutes? Also, since you are directly controlling that load, it would turn on when you press on?

Link to comment

You are absolutely right, if the switch itself controls the load either directly or through a scene then this is all you need. In fact this is preferred if you can do it because if the ISY is powered off, the switch itself will still work.

 

The program I posted shows how to use a pure program solution, which is only required if you use the receipt of X10 message (for example) instead of pressing an Insteon button.

 

Why does this have to be this complicated?

 

If you are using the switch that is the load that you want to time, don't you simply need something like this?

 

If

Control 'Fan' is On

Then

Wait 5 minutes

Set 'Fan' Off

 

 

Shouldn't this allow you to press off to cancel and reset anytime before 5 minutes? Also, since you are directly controlling that load, it would turn on when you press on?

Link to comment

If the user had subsequently pressed 'Fast On', 'Fast Off', or anything other than 'On' then the 'If' condition would no longer be true.

 

If this was done, say, 7 minutes into waiting the 10 minutes, the 'Then' immediately stops running, and the 'Finally' starts running. If you didn't have an 'Off' in the Finally the light would just stay on.

 

As sfhutchi correctly points out, this is overkill for Insteon switches because the program does everything. The simpler (and preferable) solution is to link the control to the light (using scenes etc. on the main page), and use a simple program like this:

 

If

Control is 'On'

Then

Wait 5 minutes

Set Light Off

 

In this case, the switch directly controls the light, and the only thing the program has to do is shut it off after 5 minutes.

 

 

You had to use the "Finally" there because the ISY timers are retentative and do not reset when not running? As a result they need a reset or is it for some other house keeping reason?
Link to comment

Would it be possible to include an "else" clause in the structure like:

 

If

condition(s)

then

statement(s)

else

statements(s)

finally

statement(s)

 

Here the finally clause would always execute, since either the then or else would have run.

The only way I can think to do it now is with 2 programs.

 

Thanks,

George.

 

 

Finally' is similar to 'Else' with one exception:

 

'Finally' never runs unless the 'Then' had run.

 

This means that the conditions in the 'If' had to become true, and then become false.

 

marksanctuary wrote:

Is the Finally an "else" statement?

Link to comment
'Finally' is similar to 'Else' with one exception:

 

'Finally' never runs unless the 'Then' had run.

 

This means that the conditions in the 'If' had to become true, and then become false.

 

For clarification, finally does not run if all items in the 'Then' run to completion? Does it only run when the If goes false during the execution of the Then items?

Link to comment

George,

 

Can you give me an example/scenario where you would use 'Else'? In most scenarios I have gone through with 'Else', it turned out to be much cleaner just to have 2 programs.

 

Would it be possible to include an "else" clause in the structure like:

 

If

condition(s)

then

statement(s)

else

statements(s)

finally

statement(s)

 

Here the finally clause would always execute, since either the then or else would have run.

The only way I can think to do it now is with 2 programs.

 

Thanks,

George.

 

 

Finally' is similar to 'Else' with one exception:

 

'Finally' never runs unless the 'Then' had run.

 

This means that the conditions in the 'If' had to become true, and then become false.

 

marksanctuary wrote:

Is the Finally an "else" statement?

Link to comment
Can you give me an example/scenario where you would use 'Else'? In most scenarios I have gone through with 'Else', it turned out to be much cleaner just to have 2 programs.

I guess I just feel more comfortable using an ELSE when I want one of two actions to happen. It certainly is not a bug in the beta, because 2 programs can accomplish the same thing, but it might help in making our programs easier to manage.

 

Here is an example of what got me to thinking about it:

 

Let's say you normally turn your A/C's on at 5pm, but on very hot days you want to get them cranked up 1 hour earlier. In simplified form where the program runs everyday at 5pm it might look like this:

 

If

Temp > 90

then

Turn ON the AC's

wait 4 hours

else

wait 60 minutes

Turn ON the AC's

wait 3 hours

finally

Turn OFF AC's

 

Thanks

George

Link to comment

Actually, if we added 'Else', then it would have to replace 'Finally' because 'Finally' would never run. Your example program would do the 'Then' when temp > 90, as soon as it drops below, it does the 'Else', as it goes above it does the 'Then' etc.

 

 

Here is the solution using two programs, one turning it on, and another turning it off. I think its pretty straightforward.

 

If 
    Status AC is Off
  And (
          Time is 5:00PM
       Or Time is 4:00PM
      And Temp > 90
     )
Then
    Set AC on

If
     Time is 9:00PM
 And Status AC is On
Then
    Set AC off

 

'Finally' was originally intended as cleanup for time ranges, but of course applies to all types of conditions.

 

eg.

If
   From Sunset
   To   Sunrise
Then
    Set 'Security Light' On
Finally
    Set 'Security Light' Off

 

Anyway, at some point in the future we can revisit 'Else' if there is a demand for it, and it provides something that can't be done with this mechanism.

 

 

Can you give me an example/scenario where you would use 'Else'? In most scenarios I have gone through with 'Else', it turned out to be much cleaner just to have 2 programs.

I guess I just feel more comfortable using an ELSE when I want one of two actions to happen. It certainly is not a bug in the beta, because 2 programs can accomplish the same thing, but it might help in making our programs easier to manage.

 

Here is an example of what got me to thinking about it:

 

Let's say you normally turn your A/C's on at 5pm, but on very hot days you want to get them cranked up 1 hour earlier. In simplified form where the program runs everyday at 5pm it might look like this:

 

If

Temp > 90

then

Turn ON the AC's

wait 4 hours

else

wait 60 minutes

Turn ON the AC's

wait 3 hours

finally

Turn OFF AC's

 

Thanks

George

Link to comment

Chris,

 

Thanks for the explanation and examples. As you suggest, we can always bring up the 'ELSE' at a latter time, if the need arises.

 

Anyway, at some point in the future we can revisit 'Else' if there is a demand for it, and it provides something that can't be done with this mechanism.
Link to comment

Archived

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


×
×
  • Create New...