Jump to content

Program conditionally triggers another program: how?


87squirrels

Recommended Posts

I'm stuck on this one, I know I've seen a recipe for this, but I don't recall it.

 

Here's my goal, in pseudo-code:

 

If ($state_variable > 0)
   do thing a
   if (between sunset and sunrise) run program B
   set $state_variable to 0
else
endif

 

An external program will be setting the state variable to 1 when an event occurs (door opening with security system armed).

 

(Program B doesn't currently exist, but will be trivial: turn one or more lights on, possible with some delays).

 

I tried this once before with the sunset condition in program B, but it ran on its own (i.e., regardless of the state of the variable).

 

Thanks.

Link to comment

Exactly. A Disabled Program can be called from another Program. The If will be evaluated, assuming Program A calls the If section of Program B, causing either the Then or Else clause of Program B to execute.

 

Being Disabled prevents Program B from triggering itself. It does not stop another Program from calling Program B.

Link to comment
Exactly. A Disabled Program can be called from another Program. The If will be evaluated, assuming Program A calls the If section of Program B, causing either the Then or Else clause of Program B to execute.

 

Being Disabled prevents Program B from triggering itself. It does not stop another Program from calling Program B.

This is awesome info! I've been looking for a way to activate a IF statement on a program from another program for situations like this where the disabled program would run when it's not supposed to. thanks!

Link to comment

Running disabled programs works like a charm. Most of my notification programs are disabled programs that are run by other functions. Another nice use of a disabled program is when you want a timer to run without state variables affecting its operation (empty if statement, timer in then)

 

Another technique is to enable/disable programs programmatically. I think of it as "arming" the programs, then when the program runs you can "disarm" it at the end of itself or could disable it based on some timer or other state.

 

I use this as part of my garage door / entry programming. When the garage door goes up, it enables a program that detects when you open/close the mud room door (garage/main house door) and when you do, turns on a kitchen light on open and shuts off the garage light on close. But I only want this program to run when you enter the house from the garage not when you're leaving the house via the garage. The delay between opening the garage door, then opening the mud room door, prevents me running via a disabled program directly.

Link to comment

Thanks. Working fine. Here's one set of the working programs:

 

Program Security System Faulted

If
       $SECURITY_SYSTEM_FAULT > 0

Then
       Run Program 'Cond Entry Fault' (If)
       $SECURITY_SYSTEM_FAULT  = 0

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

$SECURITY_SYSTEM_FAULT is set to 1 (by the alarmWatcher) if a door is opened while the system is armed.

 

Program Cond Entry Fault (disabled)

 

If
       From    Sunset 
       To      Sunrise (next day)

Then
       Set Scene 'Stairway' On

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

Link to comment

Archived

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


×
×
  • Create New...