Jump to content

Having trouble with program re-execution logic


Illusion

Recommended Posts

I think I am having a brain failure. I should know this but I am stumped. I have a really complex program that is re-entering execution during a wait and I want to fix this today, but I cannot figure out what to do. So I made a small program that is simple and explanatory of my issue:

 

If
       Status  'Kitchen / Kitchen Fan-Light' is On
    Or Status  'Kitchen / Kitchen LEDs' is On
    Or Status  'Office / Office Fan' is On
    Or Status  'Office / Office Hutch Lights' is On

Then
       Wait  10 seconds
       Set 'Office / Office Desk Lamp' On

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


 

For this example I want the desk lamp to come on 10s after any of the other units in the if come on. The problem here is that as long as I am changing some of the units in the condition I can keep the desk lamp from coming on. Even though the program is always true as I leave one of the conditions units on, the new status of another device in the if causes a re-entry into the wait and the desk lamp does not come on.

 

So I logically split this into two programs:

 

If
       Status  'Kitchen / Kitchen Fan-Light' is On
    Or Status  'Kitchen / Kitchen LEDs' is On
    Or Status  'Office / Office Fan' is On
    Or Status  'Office / Office Hutch Lights' is On

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

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


 

If
       Program 'Test Program' is True

Then
       Wait  10 seconds
       Set 'Office / Office Desk Lamp' On

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


 

But this suffers the same issue. Even though the test program is true, and an event causes an evaluation of the status that results in 'true' so the program status does not change, the second program re-evaluates and I can keep the desk lamp from coming on as long as I change conditions in the test program before it gets through its wait, but always being true.

 

How do I set this up so the desk lamp comes on 10s after any of the other units come on, but not if all of the units are off before the wait expires?

 

In the real program, the issue is that I have lots of conditions. I want something to happen, but only after 10m of 'True'. I do not care how the conditions change, as long as it has been 'True' for 10m. If at anytime in the 10m wait there is a condition of 'False' I do not want execution.

Link to comment

Thanks for the quick reply!!

 

Works great. An interesting distinction between variables and using programs as flags. It had not occurred to me that setting up a variable as a 1 or 0 would be any different that the true-false condition of a program, but here we are. And indeed you solution works perfectly.

Link to comment
So, just out of curiosity, as the state variable idea is working great, how would we have done this before variables?

 

How about this

  
Program 1

If
       Status  'Kitchen / Kitchen Fan-Light' is On
    Or Status  'Kitchen / Kitchen LEDs' is On
    Or Status  'Office / Office Fan' is On
    Or Status  'Office / Office Hutch Lights' is On

Then
       Run program 2 then clause

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

Program 2
If
      No condition

Then
       Disable Program 1
       Wait  10 seconds
       Set 'Office / Office Desk Lamp' On
       Enable Program 1

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

 

Haven't tested it, but it should work

Link to comment
A cool idea, using disable. But my requirements are that should the conditions become false during the wait, the action does not execute.

 

Program 1

If
       Status  'Kitchen / Kitchen Fan-Light' is On
    Or Status  'Kitchen / Kitchen LEDs' is On
    Or Status  'Office / Office Fan' is On
    Or Status  'Office / Office Hutch Lights' is On

Then
       Run program 2 then clause

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

Program 2
If
      No condition

Then
       Disable Program 1
       Wait  10 seconds
       Set 'Office / Office Desk Lamp' On
       Enable Program 1

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

Program 3

If
       Status  'Kitchen / Kitchen Fan-Light' is On
    Or Status  'Kitchen / Kitchen LEDs' is On
    Or Status  'Office / Office Fan' is On
    Or Status  'Office / Office Hutch Lights' is On

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

Else
  - Enable program 1
  - Stop program 2


Link to comment

Archived

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


×
×
  • Create New...