87squirrels Posted November 14, 2013 Posted November 14, 2013 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.
LeeG Posted November 14, 2013 Posted November 14, 2013 There is no embedded If capability. Use your previous implementation, Disable Program B. That way Program B cannot trigger itself.
87squirrels Posted November 14, 2013 Author Posted November 14, 2013 So it will run when called from another program, even if disabled, and either the then or else clause will run, depending on the condition? I can work with that... Thanks.
LeeG Posted November 14, 2013 Posted November 14, 2013 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.
jgorm Posted November 14, 2013 Posted November 14, 2013 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!
jrover Posted November 14, 2013 Posted November 14, 2013 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.
87squirrels Posted November 16, 2013 Author Posted November 16, 2013 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')
Recommended Posts