Jump to content

Can a program have an "If" a program is enabled or disabled?


Recommended Posts

Posted (edited)

I am not sure I understand what you’re asking.  Are you asking whether it is possible to add a condition in one program based upon whether another program is enabled or not enabled?

Edited by oberkc
  • Like 1
Posted

I believe you need to set a variable (including init value for persistence) when enabling or disabling a program then check that variable.

Alternatively you could set that variable and have it in the if of program you would be enabling and disabling.

Posted

There is no direct way to do what you want. You will have to create a variable that toggles when you disable / enable the program of interest, and then test that variable in your new program.

  • Like 1
Posted

My favourite for almost any program/state/lighting scene now is to create a State variable and a program that controls the enable/disable.
Now you can control it via any program, and test it via any program with one line. No worrying or complex logic to see if programs may be mis-nested or confusing each other.

If
     StateVar /= 0
Then
    enable Program X
Else
    disable Program x

Posted (edited)
6 hours ago, Blackbird said:

Im surprised that it isnt in the ISY as an option the same as true or false.

I had thought it was testable in ISY, in the past. Now I see all the controls to program change those statuses but no conditional access status.

IIRC True and False were going to be defined as system variables, as an addition years ago, but expansion became paramount to UDI when Insteon was threatening collapse.

Edited by larryllix
Posted
16 hours ago, larryllix said:

My favourite for almost any program/state/lighting scene now is to create a State variable and a program that controls the enable/disable.

Sorry to hijack this thread, but I'm interested in this method. Care to explain a bit further?

Posted
3 minutes ago, mango said:

Sorry to hijack this thread, but I'm interested in this method. Care to explain a bit further?

For lighting scenes I create a state variable for each room. Then I build a folder full of different lighting levels and routines using Insteon scenes, programs and NRs to accomplish whatever I want in lighting or in one case automatic time based dimming.

In my variables I define several "constant" definitions such as:
$cMODE.OFF= 0
$cMODE.VERY.DIM = 1
$cMODE.FULLON = 9
$cMODE.WHITE.FLASH = 99
etc...

Each room theme folder program has a single condition to detect it's value like this

LivRm.theme.dim - [ID 003A][Parent 0043]

If
        $sTheme.livRm is $cMODE.DIM
 
Then
        ...set levels to DIM
Else
   - No Actions - (To add one, press 'Action')
 

When you want to set a lighting scene to whatever a single line of code from anywhere (Alexa, automatic programs, etc..) it takes two line of code like this to turn it on

LivRm.green.initiate - [ID 0049][Parent 0017]

If
        //  Alexa vocal initiated
Then
        $sTheme.livRm  = $cMODE.RESET
        $sTheme.livRm  = $cMODE.GREEN
Else
   - No Actions - (To add one, press 'Action')
 

When you need to know what scene is being used only a single test is required. No convoluted logic is required with cross testing between programs.

When you want to "borrow" a set of lights and restore them it becomes simple and reliable, like this to flash lights at midnight and restore the original levels again:

LivRm.lateWarning - [ID 00AB][Parent 0017]
If
        Time is 11:59:30PM
Then
        $LivRm.mode.saved  = $sTheme.livRm
        $sTheme.livRm  = $cMODE.RESET
        $sTheme.livRm  = $cMODE.RED.STROBE
        Wait  3 seconds
        //
        $sTheme.livRm  = $cMODE.RESET
        $sTheme.livRm  = $LivRm.mode.saved
Else
   - No Actions - (To add one, press 'Action')
 

 

 

 

  • Like 2
Posted

@mango What @larryllix describes above is an awesome approach to have lots of scenes and simple programs to call them. 

 

If you are new to this concept, the easiest way to begin thinking about it is simply creating the "variable" to be either 1 or 0.. 1 being on for the scene, 0 being off.  

Then you would have programs that would change that variable, anywhere in the Eisy and a program that simply does:

if variable is 1

then turn on scene

Else turn off scene. 

Once you get this concept you can add a variable to each scene and create lots of scenes to control the lighting simply in any part of ISY. 

Larry's nomenclature leads me to believe in his example, he has at least 4 or 5 scenes (or he is adjusting the scenes in the programs) for the living room. Each different value for the room variable (in my example 1 or 0)  triggers each different scene via programs like the above; one program for each scene (or scene setting). So because these programs are watching for that rooms variable to change and to subsequently change the scene, it is easily done in an isolated way w/o ever affecting any other lights etc. 

 

  • Like 2

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing

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

  • Forum Statistics

    • Total Topics
      37.1k
    • Total Posts
      371.5k
×
×
  • Create New...