Jump to content

Timed light programming HELP!


AustinKirby

Recommended Posts

I have a ISY-99, KeyPadLinc and deck lights plugged into a 2456S3E (ApplianceLinc). I have a program that turns on the lights at sunset and off at 11 pm--the light looks good as well as it provides safety for my guests coming up and down the steps to my front door. This all works great. Sometimes folks stay past 11 so I wrote a program so that when a buttonon the KeyPadLinc is pressed it turns on the lights for 20 minutes then turns them off. This works great if the lights are not already on. If I tap the button and it happens to be early it turns off the lights in 20 minutes--not what I want. So I added the line in the IF section that adds the condition 'Porch lights are off'--but then the time parts doesn't ever work. The lights just stay on. Any idea what gives?

 

Thanks!

Link to comment

AustinKirby

 

A Program that contains a Wait and affects the status of the device in the If often has problems. Because of the Wait the If is reevaluated and often is False the next time.

 

Post the two Programs. I am sure someone can suggest a solution.

 

Lee

Link to comment

I have an "override" button, programmed to delay turning the interior lights off at 1100p. So long as the override button is on, the lights will stay on.

 

I have achieved this in different ways, as my needs have changed. The easiest, probably, is to simply add a condition in your program that turns the lights off:

 

if
time is 1100
and status "override button" is off
then
turn lights off

 

This approach may give you an idea for your pool. LeeG probably has the best approach, though. Post your programs and others can help out.

Link to comment

Post the program, but I bet LeeG nailed it.

 

Your program probably goes somethin like this

 

if control button x is switched on

and status light y is off

 

then set light y on

wait 20 minutes

set light y off.

 

You need to realize that as soon as the first then statement "set light y on" is executed, the program will loop back and re-evaluate the if statement to false, terminating the then part and running the else part (which is blank).

 

Remember anytime you have a "status" in a program, the if statement gets evaluated every time anything happens to the status of that device. When an evaluation occurs, any then/else stuff currently running stops, and starts again according to the true/false status of the if section.

 

You can solve this problem by having a second program, I'll call it "keeping the lights on for 20". Leave the if section blank and in the then section put

 

wait 20 minutes

set light y off

 

And the first program then section should read

 

run program 'keep the lights on for 20' (then path)

set light y on

Link to comment

Thanks for the replies.

 

The suggestion for an override doesn't really address the issue. Someone may be leaving the house long after the lights have gone off and if I have to monitor the status of the lights myself what's the purpose of having it automated?

 

I'm just looking for a "turn the lights on for 20 minutes then turn them off but only if they aren't already on" program.

 

 

Here's my code:

If
       Control 'LightsOnDemand' is switched Off
   And Status  'Rope Lights (Main)' is Off

Then
       Set 'Rope Lights (Main)' Fast On
       Wait  20 minutes
       Set 'Rope Lights (Main)' Fast Off

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

 

I'm a bit bewildered that "wait" triggers an action. Very counter intuitive. There's some smart people here and it just doesn't seem like it should be very complicated.

Link to comment

Austin,

 

Please read my post, they may have "crossed in the mail". I speculated correctly on your program. "wait" does not trigger an action, "set rope lights main fast on" however does. And becuase of that, the wait gets terminated.

 

If you write you program like I showed it will work.

Link to comment

AustinKirby

 

That is the problem. Statements in the Then clause execute sequentially even if the statements change the status the If is checking for. The exception is the Wait and Repeat statements. When a Wait or Repeat statement is encountered the If is reevaluated. Because the status of the Rope Lights has changed from Off to On (because of Fast On) the If evaluates to False so the statements after the Wait are not executed.

 

The interaction of Wait and Repeat relative to If reevaluation is well explained in the Wiki section on Programming. This is different from most programming models and catches most folks.

 

There are various solutions to this problem. The standard solution is to break the logic into two programs. The first has the If statement and a Then that invokes the second program. The second program has no If statement so the Wait is not affected by the Rope Light status change.

 

Lee

Link to comment

LeeG and apostolakisl,

 

Thanks! Works perfectly.

 

I'm a programmer by day but new to this ISY thing. I'm having to twist my head a bit to grasp the --not always-- logic of this device. It's essential that people like you help us newbies. Much appreciated!

 

One clarification, please. LeeG said

When a Wait or Repeat statement is encountered the If is reevaluated

 

But apostolakisl said

"wait" does not trigger an action

 

I'm still having trouble grasping the concept here. If there's another discussion on this forum about this, feel free to redirect me. Thanks, again.

Link to comment

AustinKirby

 

This is from the Wiki. There is a lot of good information there.

 

"Within the Then or Else clause of a program, statements are executed from top to bottom in the order in which they occur. When a statement calls another program, the called program begins executing, and the calling program immediately continues execution with the next statement in sequence--it does not wait for the called program to complete before continuing.

 

A series of statements within a Then clause (or within an Else clause), up to the next Wait or Repeat statement, are atomic. In other words, all such statements are executed before the conditions of the program are retested. The program's conditions are reevaluated each time a Wait or Repeat statement is encountered, and at the end of each iteration of a Repeat loop.

 

What this means is that if a program's Then clause changes a condition which causes the program's overall condition to become false (or if the program's Else clause changes a condition which causes the program's overall condition to become true), the current atomic statement group will complete, and at that point execution will transfer from the Then clause (or the Else clause) to the Else clause (or the Then clause).

 

Therefore, if a Then clause (or an Else clause) contains no Wait or Repeat statements, the entire clause is atomic, and will complete before the program's conditions are reevaluated."

 

Changing the conditions the If checks DOES NOT in and of itself cause execution of the clause to stop. It must encounter a Wait or Repeat for the If to be reevaluated.

 

Lee

Link to comment

I think the best way to think of this is that a "wait" gives the if clause the opportunity to be re-evaluated. If there are no statements in the if clause that behave as triggers, the if clause doesn't re-evaluate and the program keeps on its merry way. If a trigger condition does exist in the if section, the program stops and then runs again according to how the "if" section plays out now.

 

Everything before a "wait" or "repeat" executes regardless. The logic runs all of the lines of the then statement in parrallel (or at least nothing can get in the way of it progressing through all of them) until it hits a wait or repeat. But "wait/repeat" itself, as well as the stuff after a "wait" or "repeat" is subject to the "if" clause not re-evaluating. Any statement in the if section that triggers after the original trigger will restart the program, even if it evaluates to the same thing (true/false).

 

For example

 

If

status light x is not off

 

then

wait 5 minutes

do something

 

status is a trigger whenever the status changes. So, if I turn light x on, the 5 minute timer starts running. If during that 5 minutes, I dim the lights, the timer restarts. Even though the program was always true (on and dimmed both qualify as true in this program).

 

Edit: After reading LeeG's stuff, I think there are some slight differences on what he and I mean to say evaluate. When I say evaluate, I mean that the if clause has been triggered and the program is actively moving towards a "then" or "else" result. I think he means that it is available for testing of the conditions in the event of a trigger.

 

And there is a point in LeeG's statement that implies an incorrect point. The status of the if clause does not need to change from true to false or vice-versa for the program to interupt the then statement. Anything that triggers the if section to be reassesed (a trigger) kills the program, period. So any then/else statement that has not already been sent off, will not happen. If the status stays the same, it will rerun (from the beginning) the then (or else) statement.[/i]

Link to comment

AustinKirby

 

The following conclusion

 

“Anything that triggers the if section to be reassesed (a trigger) kills the program, period. So any then/else statement that has not already been sent off, will not happen.â€

 

Is not correct.

 

I hate to get into such a detailed explanation but cannot let you go away with that idea. Using the following actual Program as a demonstration when I turn ICON ON OFF device to On the Program is triggered and the Then clause Runs. Eight devices are turned On in the Then Clause. When ICON ON OFF is turned OFF in the middle of the Then clause the remaining Then clause statements DO execute. Using the terminology in the Wiki the statements are atomic because no Wait or Repeat statement .

 

If

Status 'ICON ON OFF' is On

 

Then

Set 'ICON Dimmer 1' On

Set 'ICON xxxx' On

Set 'InLineLinc' On

Set 'KeypadLinc White Box' On

Set 'KeypadLinc-3' On

Set 'KeypadLinc-4' On

Set 'KeypadLinc6Bas8B' On

Set 'Keypadlinc6Button' On

 

Else

Send X10 'A8/Off (11)'

 

 

Event Viewer trace –

ICON ON OFF is turned ON, Program is triggered, Then Clause starts

The first 4 Set statement are executed

ICON ON OFF is turned OFF, Program is triggered, Else Clause starts

Original Then Clause statements continue execution, the remaining statements in the Then Clause are NOT aborted/cancelled.

 

 

Tue 05/17/2011 11:39:23 AM : [iNST-SRX ] 02 50 04.56.50 00.00.01 CB 11 00 LTONRR (00) 'ICON ON OFF' turned On

 

Program is triggered by 'ICON ON OFF' turning ON - Then Clause begins execution because If is True

 

Tue 05/17/2011 11:39:23 AM : [iNST-ACK ] 02 62 15.B2.6A 0F 11 FF 06 LTONRR (FF) 'ICON Dimmer 1' On

 

Tue 05/17/2011 11:39:24 AM : [iNST-ACK ] 02 62 15.52.C8 0F 11 FF 06 LTONRR (FF) ‘ICON xxxx' On

 

Tue 05/17/2011 11:39:24 AM : [iNST-ACK ] 02 62 13.28.91 0F 11 FF 06 LTONRR (FF) 'InLineLinc' On

 

Tue 05/17/2011 11:39:25 AM : [iNST-ACK ] 02 62 0C.8C.3B 0F 11 FF 06 LTONRR (FF) 'KeypadLinc White Box' On

 

 

Tue 05/17/2011 11:39:25 AM : [iNST-SRX ] 02 50 04.56.50 00.00.01 CB 13 00 LTOFFRR(00) 'ICON ON OFF' turned Off

 

Program is triggered by 'ICON ON OFF' turning OFF - Else Clause begins execution because If is False

 

The previous Program execution continues until all Tnen Clause statements are executed

 

Tue 05/17/2011 11:39:25 AM : [iNST-ACK ] 02 62 14.71.3C 0F 11 FF 06 LTONRR (FF) 'KeypadLinc-3' On

 

 

Tue 05/17/2011 11:39:25 AM : [ X10] A8 Else Clause statement executes from ICON ON OFF Off trigger

 

Tue 05/17/2011 11:39:25 AM : [ X10] A8/Off (11)

 

 

Tue 05/17/2011 11:39:26 AM : [iNST-ACK ] 02 62 0B.4A.AD 0F 11 FF 06 LTONRR (FF) 'KeypadLinc-4' On

 

Tue 05/17/2011 11:39:26 AM : [iNST-ACK ] 02 62 08.49.E7 0F 11 FF 06 LTONRR (FF) 'KeypadLinc6Bas8B' On

 

Tue 05/17/2011 11:39:27 AM : [iNST-ACK ] 02 62 15.9A.F9 0F 11 FF 06 LTONRR (FF) ' Keypadlinc6Button' On

 

 

It is okay not to follow all the detail of the actual Program execution and Event Trace. That will come with time. The key thing to remember is the change in If Trigger does not abort/cancel atomic group of statements that do not contain a Wait/Repeat.

 

Lee

Link to comment

ISY programming is a little different but it is fun and very capable.

 

If you write the program how I demo'd earlier it will do what you want. But you could make it better. For example, say the time is 10:55 and you are walking your guests out. You don't want the light to shut off at 11. You should think about re-writing things so that pushing that button keeps the light on past 11. At present, pushing that button won't stop the 11pm off command from executing.

 

Typically you separate the program that automatically turns the lights on from the one that turns them off at 11. Then in the one that turns them off you can put more if clauses that block it from running in the event that you have pushed your button. Variables are a good way to do that.

 

It can all be great fun! yeah! You have to be a geek!

 

Also, highly suggest using folders to nest these programs otherwise you will have a hard time organizing things. And using the memo section helps to. It all seems so obvious when you write it, then a year later you look at it and go "what the heck was I trying to do here"

Link to comment

Apostolakisl, I had already thought of that scenario! My solution was to program a lamp to flicker at 10:40 at which time I would inform my guests that they had to either leave immediately or wait until after 11 pm.

 

OK, not very elegant. My first plan would have the control toggle ON then after 20 minutes of light I would tell it to go OFF. Unfortunately I haven't found a way to make the control go OFF. That's why I have it in Non-Toggle (OFF) mode--it just sends a command then goes back to sleep.

 

Use variables? Hey, that's for rock stars. I'm not that advanced --yet-- but I've embraced my geekness enough to know that day will come. If fact, I'm geek enough to have read all of LeeG's program trace. That's serious. I knew I was bad off when I announced to my wife that with merely $450 of equipment I was able to turn on the rope lights. A task previously available only to a $25 timer or (shiver) a manual light switch.

 

I love playing with this stuff.

 

As far as how capable the ISY is, I'm not convinced yet. It seemed like making a control go OFF would be a simple task but I haven't found a way. Any thoughts?

Link to comment
AustinKirby

 

The following conclusion

 

“Anything that triggers the if section to be reassesed (a trigger) kills the program, period. So any then/else statement that has not already been sent off, will not happen.â€

 

Is not correct.

 

I hate to get into such a detailed explanation but cannot let you go away with that idea. Using the following actual Program as a demonstration when I turn ICON ON OFF device to On the Program is triggered and the Then clause Runs. Eight devices are turned On in the Then Clause. When ICON ON OFF is turned OFF in the middle of the Then clause the remaining Then clause statements DO execute. Using the terminology in the Wiki the statements are atomic because no Wait or Repeat statement .

 

If

Status 'ICON ON OFF' is On

 

Then

Set 'ICON Dimmer 1' On

Set 'ICON xxxx' On

Set 'InLineLinc' On

Set 'KeypadLinc White Box' On

Set 'KeypadLinc-3' On

Set 'KeypadLinc-4' On

Set 'KeypadLinc6Bas8B' On

Set 'Keypadlinc6Button' On

 

Else

Send X10 'A8/Off (11)'

 

 

Event Viewer trace –

ICON ON OFF is turned ON, Program is triggered, Then Clause starts

The first 4 Set statement are executed

ICON ON OFF is turned OFF, Program is triggered, Else Clause starts

Original Then Clause statements continue execution, the remaining statements in the Then Clause are NOT aborted/cancelled.

 

 

Tue 05/17/2011 11:39:23 AM : [iNST-SRX ] 02 50 04.56.50 00.00.01 CB 11 00 LTONRR (00) 'ICON ON OFF' turned On

 

Program is triggered by 'ICON ON OFF' turning ON - Then Clause begins execution because If is True

 

Tue 05/17/2011 11:39:23 AM : [iNST-ACK ] 02 62 15.B2.6A 0F 11 FF 06 LTONRR (FF) 'ICON Dimmer 1' On

 

Tue 05/17/2011 11:39:24 AM : [iNST-ACK ] 02 62 15.52.C8 0F 11 FF 06 LTONRR (FF) ‘ICON xxxx' On

 

Tue 05/17/2011 11:39:24 AM : [iNST-ACK ] 02 62 13.28.91 0F 11 FF 06 LTONRR (FF) 'InLineLinc' On

 

Tue 05/17/2011 11:39:25 AM : [iNST-ACK ] 02 62 0C.8C.3B 0F 11 FF 06 LTONRR (FF) 'KeypadLinc White Box' On

 

 

Tue 05/17/2011 11:39:25 AM : [iNST-SRX ] 02 50 04.56.50 00.00.01 CB 13 00 LTOFFRR(00) 'ICON ON OFF' turned Off

 

Program is triggered by 'ICON ON OFF' turning OFF - Else Clause begins execution because If is False

 

The previous Program execution continues until all Tnen Clause statements are executed

 

Tue 05/17/2011 11:39:25 AM : [iNST-ACK ] 02 62 14.71.3C 0F 11 FF 06 LTONRR (FF) 'KeypadLinc-3' On

 

 

Tue 05/17/2011 11:39:25 AM : [ X10] A8 Else Clause statement executes from ICON ON OFF Off trigger

 

Tue 05/17/2011 11:39:25 AM : [ X10] A8/Off (11)

 

 

Tue 05/17/2011 11:39:26 AM : [iNST-ACK ] 02 62 0B.4A.AD 0F 11 FF 06 LTONRR (FF) 'KeypadLinc-4' On

 

Tue 05/17/2011 11:39:26 AM : [iNST-ACK ] 02 62 08.49.E7 0F 11 FF 06 LTONRR (FF) 'KeypadLinc6Bas8B' On

 

Tue 05/17/2011 11:39:27 AM : [iNST-ACK ] 02 62 15.9A.F9 0F 11 FF 06 LTONRR (FF) ' Keypadlinc6Button' On

 

 

It is okay not to follow all the detail of the actual Program execution and Event Trace. That will come with time. The key thing to remember is the change in If Trigger does not abort/cancel atomic group of statements that do not contain a Wait/Repeat.

 

Lee

 

I might have spread my answer out and not been as specific in the first paragraph as I should have been, but the topic was in the presence of "wait" statements and that was what I referred to. If you read paragraph two I was very clear in stating that the then clause is not interuptible until you hit the wait statement, then the program gets killed if a trigger event should happen.

Link to comment
Apostolakisl, I had already thought of that scenario! My solution was to program a lamp to flicker at 10:40 at which time I would inform my guests that they had to either leave immediately or wait until after 11 pm.

 

OK, not very elegant. My first plan would have the control toggle ON then after 20 minutes of light I would tell it to go OFF. Unfortunately I haven't found a way to make the control go OFF. That's why I have it in Non-Toggle (OFF) mode--it just sends a command then goes back to sleep.

 

Use variables? Hey, that's for rock stars. I'm not that advanced --yet-- but I've embraced my geekness enough to know that day will come. If fact, I'm geek enough to have read all of LeeG's program trace. That's serious. I knew I was bad off when I announced to my wife that with merely $450 of equipment I was able to turn on the rope lights. A task previously available only to a $25 timer or (shiver) a manual light switch.

 

I love playing with this stuff.

 

As far as how capable the ISY is, I'm not convinced yet. It seemed like making a control go OFF would be a simple task but I haven't found a way. Any thoughts?

 

ISY is going to take care of you, don't worry.

 

First off, write one simple program to turn the lights on at sunset.

 

Right a second program to turn the lights off at 11pm. But include a stipulation that a variable should equal something, like 0 for it to happen.

 

Right a third program that says if button x is pushed, turn the light on and set variable to 1, wait 20 minutes set to zero.

 

Right another program that says when variable becomes 0, and time is after 11pm, turn the light off.

 

 

Now, whenever you push that button, the light will stay on for 20 minutes, or until 11pm, whichever is later. And if you pushed it once, and then 5 minutes later you push it again, it will reset to 20 minutes again.

 

Sorry I didn't write this in full out program language, but I am not at a computer that I can get to my ISY language.

Link to comment
As far as how capable the ISY is, I'm not convinced yet. It seemed like making a control go OFF would be a simple task but I haven't found a way. Any thoughts?

 

This is so simple I am concerned that I am misunderstanding. How about:

 

If 
       Control 'LightsOnDemand' is switched On 
   And Status  'Rope Lights (Main)' is Off 

Then 
       Run timer program "then path"  
Else 
  - No Actions - (To add one, press 'Action') 

Timer Program:

if

then
Set 'Rope Lights (Main)' Fast On 
       Wait  20 minutes 
       Set 'Rope Lights (Main)' Fast Off 
       Set 'lightsOnDemand' off

else

 

I had already thought of that scenario! My solution was to program a lamp to flicker at 10:40 at which time I would inform my guests that they had to either leave immediately or wait until after 11 pm.

 

I know you didn't like my override suggestion, but this is the exact scenerio for which it was intended....manually delaying the automatic shutdown. You could do both, and use the same button for the override as you do for your 20 minute timer.

 

I knew I was bad off when I announced to my wife that with merely $450 of equipment I was able to turn on the rope lights. A task previously available only to a $25 timer or (shiver) a manual light switch.

I actually heard my wife admit she liked the automation. Unfortunately, this did not happen until four years and several thousand dollars was gone. You will convert her, if she is not already.

 

I love playing with this stuff.

 

Me too.

Link to comment

If 
    Time is Sunset
Then
    Set 'rope lights (Main)' on



If
    control 'lightsOnDemand' is switched On
Then
    Set 'rope lights (Main)' on
    $State_1 = 1
    Wait 20 minutes
    $State_1 = 0
    Set 'lightsOnDemand' Off



If
    From 11:00:00pm
    To Sunset - 1 second (Next Day)
 And
    $State_1 = 0
Then
    Set 'Rope Lights (main)' Off

 

I have assume the 'rope lights (main)' is the load carrying switch.

I also assumed that 'lights on demand' is kpl button or some other switch that is only used to initiate that 20 minute extra.

 

I haven't tested the program series, but think it should work.

 

If 'lights on demand' is a kpl, you will need to turn it off, then back on to reset the timer. If it is a switchlinc, just hitting the up paddle will reset it.

Link to comment

oberkc,

 

After considering the ultimate purpose of this program -to provide an after hours option to turn on the lights - I think your solution actually is best. I thought I wanted the lights to turn off after 20 minutes but sometimes I might want them on longer; or shorter. Yes, I have to manually turn them off but that's part of my good night routine, anyway. It helped that I thought of this as "manual mode" rather than "override".

 

Thanks for your suggestion.

Link to comment

Archived

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


×
×
  • Create New...