ISY-99i Series INSTEON:IR Example - KeypadLinc-style Button Control

From Universal Devices, Inc. Wiki
Jump to: navigation, search

This article will show how a group of small programs can allow a single IR command (button) to turn on and off, fast on and fast off, and brighten and dim, a device or scene. In the case of bright and dim, each hold/release will reverse the direction of fade from the previous fade, mimicking the behavior of a KeypadLinc button. The eight small programs look like this:

Program Light 1 On

If
        IR 'Button 1' is Pressed
    And Status  'Light 1' is Off

Then
        Set 'Light 1' On
        Run Program 'Light 1 Fade Direction' (Else Path)

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

Program Light 1 Off

If
        IR 'Button 1' is Pressed
    And Status  'Light 1' is not Off

Then
        Set 'Light 1' Off
        Run Program 'Light 1 Fade Direction' (Then Path)

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

Program Light 1 Fast On

If
        IR 'Button 1' is Double Pressed
    And Status  'Light 1' is Off

Then
        Set 'Light 1' Fast On
        Run Program 'Light 1 Fade Direction' (Else Path)

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

Program Light 1 Fast Off

If
        IR 'Button 1' is Double Pressed
    And Status  'Light 1' is not Off

Then
        Set 'Light 1' Fast Off
        Run Program 'Light 1 Fade Direction' (Then Path)

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

Program Light 1 Bright

If
        IR 'Button 1' is Held
    And Program  'Light 1 Fade Direction' is True

Then
        Set 'Light 1' Fade Up

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

Program Light 1 Dim

If
        IR 'Button 1' is Held
    And Program  'Light 1 Fade Direction' is False

Then
        Set 'Light 1' Fade Down

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

Program Light 1 Fade Stop

If
        IR 'Button 1' is Released

Then
        Set 'Light 1' Fade Stop
        Run Program 'Light 1 Fade Direction' (If)

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

Program Light 1 Fade Direction - NOT Enabled

If
        If Program 'Light 1 Fade Direction' is False

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

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

The Light 1 On and Light 1 Off programs are fairly self-explanatory: when Button 1 is pressed, Light 1 is turned On if it is Off, otherwise it is turned Off. Light 1 On then does a call to Light 1 Fade Direction (Else Path), setting the status of that program to False, while Light 1 Off does a call to the program's Then Path, setting the program's status to True, to set the direction for the next fade. This ensures that when Light 1 is off, the next fade will fade up (and vice versa), regardless of the direction of the previous fade.

Light 1 Fast On and Light 1 Fast Off are the same as the previous two programs, except that they do a Fast On or Fast Off, respectively.

The Light 1 Bright, Light 1 Dim, and Light 1 Fade Stop programs should also be easily understood: when Button 1 is held, Light 1 begins a fade up or down, depending on the state of the flag program Light 1 Fade Direction; when Button 1 is released, the fade is stopped, after which Light 1 Fade Direction is called to reverse its state for the next fade--if it was False it becomes True, and vice versa. It is important to note that the Light 1 Fade Direction program does not have its Enabled checkbox checked. This ensures that the flag program only changes its state when explicitly called from one of the other programs.

Alternatively, the same functionality could be obtained with the following six small programs:

Program Light 2 On/Off

If
        IR 'Button 2' is Pressed

Then
        Run Program 'Light 2 Toggle' (If)

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

Program Light 2 Toggle - NOT Enabled

If
        Status 'Light 2' is Off

Then
        Set 'Light 2' On
        Run Program 'Light 2 Fade Direction' (Else Path)
        Stop Program 'Light 2 Fade Direction'

Else
        Set 'Light 2' Off
        Run Program 'Light 2 Fade Direction' (Then Path)
        Stop Program 'Light 2 Fade Direction'

Program Light 2 Fast On/Fast Off

If
        IR 'Button 2' is Double Pressed

Then
        Run Program 'Light 2 Fast Toggle' (If)

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

Program Light 2 Fast Toggle - NOT Enabled

If
        Status 'Light 2' is Off

Then
        Set 'Light 2' Fast On
        Run Program 'Light 2 Fade Direction' (Else Path)
        Stop Program 'Light 2 Fade Direction'

Else
        Set 'Light 2' Fast Off
        Run Program 'Light 2 Fade Direction' (Then Path)
        Stop Program 'Light 2 Fade Direction'

Program Light 2 Fade

If
        IR 'Light 2' is Held
    And IR 'Light 2' is not Released

Then
        Run Program 'Light 2 Fade Direction' (If)

Else
        Set 'Light 2' Fade Stop

Program Light 2 Fade Direction - NOT Enabled

If
        If Program 'Light 2 Fade Direction' is False

Then
        Set 'Light 2' Fade Down

Else
        Set 'Light 2' Fade Up

Here the Bright, Dim and Fade Stop programs are combined into a single Light Fade program, saving two programs. This single program calls Light Fade Direction, which determines the direction of fade, begins the fade, and reverses the direction flag for the next call.

The On, Off, Fast On and Fast Off programs have been similarly configured for symmetry, although they could just as easily be configured as in the first example. Note that these programs, after calling the Direction program to set its state, must now immediately follow such a call with a Stop of that program to prevent its contents from being executed, since it is no longer an empty program. Also note that in addition to the Direction program, each of the Toggle programs is not enabled.

While this second example saves two programs per button as compared to the first example, the extra program call does add a small additional amount of latency to each action. While difficult to measure precisely, this delay seems to be in the neighborhood of one-half to one second. For this reason, the first example may be preferred.

These sets of example programs have been exported from ISY, and are available here for download and import into your own ISY. The first example is in Light_1.isy, found in Light_1.zip, and the second example in Light_2.isy, found in Light_2.zip:

To use these example programs, download and unzip the .zip file. Next, in the ISY Administrative Console's Program Details tab, right-click on My Programs and select Import, then browse to the .isy file extracted from the .zip file you downloaded. The example programs will be imported into a folder named Light 1 (or Light 2), which you can rename. Edit each program to use your own devices. Once your programs are correct, you can right-click on the folder and choose Copy Tree to create folders for additional devices, as required.




ISY-99i Series INSTEON : How-To Guide