Jump to content

Random ON/OFF Program?


jerlands

Recommended Posts

Posted

I'm trying to randomly turn ON then OFF a light between sunset and 10pm. I'd like to narrow the "random" range somewhat by not starting at 0 minutes but i don't see how to do that right now.

 

 

Front Bedroom Light A

 

If

From Sunset

To 10:00:00PM (same day)

 

Then

Repeat 4 times

Run Program 'Front Bedroom Light B' (If)

 

Else

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

 

 

 

Front Bedroom Light B

 

If

From Sunset

To 9:00:00PM (same day)

 

Then

Wait 20 minutes (Random)

Set 'Front Bedroom Light' On

Wait 20 minutes (Random)

Set 'Front Bedroom Light' Off

Wait 40 minutes

 

Else

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

 

 

Thanks,

 

Jon

Posted
You can have two Wait commands back-to-back--one can be a fixed minimum time, the second can be a random time.

 

Ah... Good Idea :D

 

Just not thinkin' I guess....

 

Jon

Posted

jerlands,

 

I have spent little time in Houston, but is it possible that the period of time between sunset and 9:00pm is less than 40 minutes during certain times of the year? If so, is there a risk that your Front Bedroom Light B program may evaluate as false during the second wait period, causing a failure to turn the light off in extreme random cases?

 

Out of curiousity, why did you include "if" conditions as part of the second program?

Posted
jerlands,

 

I have spent little time in Houston, but is it possible that the period of time between sunset and 9:00pm is less than 40 minutes during certain times of the year? If so, is there a risk that your Front Bedroom Light B program may evaluate as false during the second wait period, causing a failure to turn the light off in extreme random cases?

 

Out of curiousity, why did you include "if" conditions as part of the second program?

 

Simply, I don't want it to run past 10pm... I don't care when it starts, just not past ten. If it doesn't run that's fine... I don't think the fact it's evaluated as false is going to harm the ISY or burn down the house.

Posted
I don't think the fact it's evaluated as false is going to harm the ISY or burn down the house.

Yeah, burning the house down would be bad. But if it (your second program, conditions from sunset to 9:00p) evaluates as false during one of your wait statements, you may exerience a case where the lights fail to go off as expected.

 

If your sunsets are as late as ours in the summer months, you could frequently have a condition where your lights are on, your program is the second "wait" period, and 9:00p occurs. At this time, the second program's conditions would trigger an evaluation, which would cease the program execution before the light is turned off. For that matter, it could happen at any time of the year since you repeat the program up to four times.

 

Do you have your second program "disabled"?

 

Anyhow, if you experience this condition (lights remaining on after you expect them to be off), you may want to look at this as a possibility.

Posted

If your sunsets are as late as ours in the summer months, you could frequently have a condition where your lights are on, your program is the second "wait" period, and 9:00p occurs. At this time, the second program's conditions would trigger an evaluation, which would cease the program execution before the light is turned off. For that matter, it could happen at any time of the year since you repeat the program up to four times.

 

Do you have your second program "disabled"?

 

 

I was thinking the logic was ladder like... if the IF statement is true it goes to THEN... once THEN is executing I didn't think it returned to the IF condition (or be affected by the fact it's FALSE.)

 

The second program isn't disabled because nothing would happen if it were.

 

Jon

Posted

jerlands

 

The Wait and Repeat change that assumption. Any time a Wait or Repeat is encountered the If condition can be evaluated such that the Then is repeated from the beginning (such as could happen with If Control On and another On command is received) or the remaining statements are not executed at all because the If has changed from True to False.

 

That is why Programs with Wait and Repeat often have no If statements.

 

Lee

Posted
jerlands

 

The Wait and Repeat change that assumption. Any time a Wait or Repeat is encountered the If condition can be evaluated such that the Then is repeated from the beginning (such as could happen with If Control On and another On command is received) or the remaining statements are not executed at all because the If has changed from True to False.

 

That is why Programs with Wait and Repeat often have no If statements.

 

Lee

 

So in my program, WAIT causes a re-evaluation of IF?

Posted
So in my program, WAIT causes a re-evaluation of IF?

That is not completely accurate. WAIT (or REPEAT) statements don't CAUSE re-evaluation. Rather, I understand it as returning control of the program to the "if" statement SHOULD the IF conditions change.

 

In your case in the second program, your "if" condition would be evaluated at at two times only: sunset and at 9:00pm. (This is what CAUSES the evaluation). If, by chance, the evaluation occurs during a WAIT or REPEAT statement, then the program will be interrupted.

 

I was thinking the logic was ladder like

This is true except in the cases where your program steps include WAIT or REPEAT. I now understand why your second program has a 40 minute wait period at the end.

 

I suggest a different approach to your programs:

 

Front Bedroom Light A 

If 
From Sunset 
To 9:00:00PM (same day) 

Then 
Repeat 4 times 
Run Program 'Front Bedroom Light B' (then)
Wait 40 minutes 

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

Front Bedroom Light B 

If 

Then 
Wait 20 minutes (Random) 
Set 'Front Bedroom Light' On 
Wait 20 minutes (Random) 
Set 'Front Bedroom Light' Off 

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

The performance of your program would be slightly different, but I suspect in acceptable ways. I think, too, that this will lessen the chance that you will find lights on all night.

Posted

I see.. I don't understand though why there is "Wait 40 minutes" now in "A?"

 

June 21 in Houston sunset is around 8:30pm and 5:30pm Dec. 21. I'm assuming it's "sunset" that starts the program so I think the following would work and not run past 10pm.

 

 

 

Front Bedroom Light A

 

If

From Sunset - 30 minutes

To 9:00:00PM (same day)

 

Then

Repeat 4 times

Run Program 'Front Bedroom Light B' (If)

 

Else

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

 

 

 

Front Bedroom Light B

 

 

If

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

 

Then

Wait 10 minutes

Wait 10 minutes (Random)

Set 'Front Bedroom Light' On

Wait 3 minutes

Wait 10 minutes (Random)

Set 'Front Bedroom Light' Off

Wait 25 minutes

 

Else

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

 

 

 

 

Thanks,

 

Jon

Posted

Make sure you choose the "then" path

 

Front Bedroom Light A

If
From Sunset - 30 minutes
To 9:00:00PM (same day)

Then
Repeat 4 times
Run Program 'Front Bedroom Light B' (then)<<wait 40 minutes<<
Else
- No Actions - (To add one, press 'Action') 

 

I see.. I don't understand though why there is "Wait 40 minutes" now in "A?

 

I continue to believe it conceivable that the 40 (or some time) delay is advisable, but that it must be in program A (rather than the 25 minute delay in B). Otherwise the program "then" path will run 4 consecutive times immediately, with the second, third, and fourth times starting before the first, second, and third occurrences finish. The reason I say this is that I don't believe that the repeat will wait until the end of program B before starting (repeating) again. Given this understanding, I also don't believe the 25 minute wait in program B will have any effect.

 

If it is mandatory lights out at 10:00, you can always modify the programs to look like this, to be sure:

 

Front Bedroom Light A

If
From Sunset - 30 minutes
To 9:00:00PM (same day)

Then
Repeat 4 times
Run Program 'Front Bedroom Light B' (then path)
wait 40 minutes

Else
- Set 'Front Bedroom Light' Off <<

Posted

I tried several tests and "repeat" didn't work in the two program scheme. It does work when used in the same program.

 

Thanks,

 

Jon

Posted

I am not sure I followed. Two program scheme versus same program? When you say it does not work...care to clarify? How are you sure.

 

I enjoy this kind of problem and it helps me better understand the ISY programming. If you care to post your latest program, I would love to see it.

Posted

These are examples of my test. Originally I had "WAIT" at the end of program "B" and removed the line cause it didn't repeat. REPEAT doesn't work for this program.

 

EDIT... Oops... it will work if you place "WAIT" after RUN Program 'Test B' (Then Path) as you originally mentioned.

 

TEST A

 

If

From 11:15:00AM

To 11:20:00AM (same day)

 

Then

Repeat 4 times

Run Program 'TEST B' (Then Path)

 

Else

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

 

TEST B

 

If

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

 

Then

Set 'Media Room Light' On

Wait 10 seconds

Set 'Media Room Light' Off

 

Else

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

 

 

 

 

The final program ...

 

If

From Sunset - 30 minutes

To 10:00:00PM (same day)

 

Then

Repeat 5 times

Wait 10 minutes

Wait 15 minutes (Random)

Set 'Front Bedroom Light' On

Wait 10 minutes (Random)

Set 'Front Bedroom Light' Off

Wait 25 minutes

 

Else

Set 'Front Bedroom Light' Off

 

 

Jon

Posted

Something clicked and I realized what you were saying about having to place "Wait" after the instruction following "Repeat." When calling another program "Wait" needs to equal the length of time required for that program to complete.

 

This seems to work.

 

 TEST A
If
       From    11:54:00AM
       To      11:56:00AM (same day)

Then
       Repeat 4 times
          Run Program 'TEST B' (Then Path)
          Wait  13 seconds

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

 

 

 

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

Then
       Set 'Media Room Light' On
       Wait  10 seconds
       Set 'Media Room Light' Off

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


Posted
When calling another program "Wait" needs to equal the length of time required for that program to complete.

 

That is what I was thinking. It looks as if you have confirmed this. Your test program looks exactly like what you need to do with your lights, except without the random parts. I am glad it works for you.

Guest
This topic is now closed to further replies.

  • Recently Browsing

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

  • Forum Statistics

    • Total Topics
      37k
    • Total Posts
      371.4k
×
×
  • Create New...