Jump to content

Wait versus separate Off program


johncrab

Recommended Posts

I brought some old X10 baggage to the ISY and in that world there was not "wait" command, so a separate off program was needed to turn something off. I have been using the wait command quite a bit wand was wondering if this is a better and more secure way to go than a separate off pgm or if we're just talking a matter of style and concise code. Just curious for feedback on this.

Link to comment

The only technical matter is that a Wait (and Repeat) allows the If section to be reevaluated if the conditions in the If section have changed before or during the Wait. This can prevent statements following the Wait not to be executed. This can have advantages as a new Wait interval is established. For example, a Program is triggered each time Motion is sensed with a Wait and Off of some responder when the Wait expires. Each new motion sensed triggers the Program and establishes a new Wait time. Only when the Wait time expires with no motion do the statements after the Wait execute.

 

This can also work against the logic of the Program where the reevaluation during a Wait prevents statements after the Wait from executing. In this case a simple solution is to move the Then logic into a second Program with an empty If. That way the Wait does not cause a reevaluation. Just depends on what the Program is trying to accomplish.

 

I tend to put related logic together in the same Program but this is personal choice.

Link to comment

For me, my choice of wait or second program depends on duration mostly. If a couple of seconds, I would be more inclined to use a wait. If on order of hours, I would use a second program. Other factors also come into play...powerfailure during wait...conditions that can be retriggered by THEN statements...etc....

 

All other things being equal, it is a style issue in my mind. Unfortunately, things are rarely equal.

Link to comment

Lee, thanks for your specific example. I use a number of motion sensors and have a separate off program for each on program to respond to the sensor's off command, relying on the sensor's timer. If I use a wait instead, I can effectively bypass the internal timer and let the ISY time the event based on when the sensor is no longer triggered and effectively change the on time from my keyboard rather than by reprogramming the sensor. That's a cool take on it.

Link to comment

The power outage issue is a compelling reason not to use wait, Lee.

 

I am currently using a EZFlora wherein program has a "wait" of 24 hours due to rain (a variable to flagged to 1 as well)

 

What do you think is the best way to use a "program" and execute it after 24 hours (instead of wait), only if the conditions are met.

 

Thanks.

Link to comment
The power outage issue is a compelling reason not to use wait, Lee.

 

I am currently using a EZFlora wherein program has a "wait" of 24 hours due to rain (a variable to flagged to 1 as well)

 

What do you think is the best way to use a "program" and execute it after 24 hours (instead of wait), only if the conditions are met.

 

Thanks.

 

For a fool proof way to push something off for 24 hours, use the ISY day of week function. Set a variable on boot or at midnight to set a variable to the current day of week (1 for Mon, 2 for Tues, etc).

 

If
       On Mon
       Time is 12:00:01AM

Then
       $iDay.of.Week  = 1

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


etc for each day of week

 

Then your program that pushes something off to the next day has a new variable that says add 1 to the current value (and roll over an 8 to a 1).

If
       whatever you want to trigger the 24 hour delay

Then
       $sTomorrow = $iDay.of.Week
       $sTomorrow += 1 (or 2, 3 ,4, 5, 6 if you want to push something off more than 1 day into the future)
       $sTomorrow Init to $sTomorrow

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

 

 

If
       $sTomorrow > 7

Then
       $sTomorrow -= 7
       $sTomorrow init to $sTomorrow

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

 

 

Then you use that variable as being equal to the current day of week variable in your "if" clause of whatever it is that is going to happen the next day.

 

If
       $iDay.of.Week is $sTomorrow
       and
       Time is ?

Then
       do whatever

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

 

You could use the same program to push something off 2 days or more up to a max of 6 days.

Link to comment

Archived

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


×
×
  • Create New...