ISY-99i/ISY-26 INSTEON:Variable Details

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

Integer Variables

  • A signed integer (32 bit)
  • Arithmetic operations available in Actions
  • Comparison operations available in conditions
  • Initialized at startup
  • Changes to the value do not cause an event to be sent


State Variables

  • Identical to an Integer variable except that changes to the value do cause an event to be sent, causing programs to run


Variables Tab

  • The definitions for all the variables is under the Variables tab in Programs.
  • When you add/remove/rename a variable you must save your changes before they will take effect.
  • When you modify either the init value or the current value the change takes place immediately and you do not have to hit save.
  • The timestamp column shows the last time the current value of the variable was changed.

In Programs

  • For both actions and conditions, variables are shown with just their name prefixed by $.
    • For example, if you define a variable named counter it will show up as $counter in your programs.


Initialization

  • At start-up, all variables are initialized to their predefined init value, or zero, if no init value has been specified. The init value may be set by editing the init value in the table containing the variable definitions.
  • The init value may also be set in programs, thus providing a means of persisting values across restarts.

x : A variable a : Either a variable or an integer constant

Initialize $x Init To a

This sets the init value for this variable, it does not modify the current value of the variable.

You may of course set the init value to the current value of the variable by doing this:

$x Init To $x


Persistence

It may be desirable to maintain the value of some variables across restarts of the ISY. This must be done explicitly by changing the init value of the variable (as described above).

One of the reasons we don't automatically persist all of the variables is that the value of a variable would have to written to persistent storage (a file on the SD Card) each time it changes.

Operators

All operations are in the form $variable op <value or variable>.

Calculations

Most operations do both a calculation and assignment, for example:

$counter += 1

is equivalent to the more familiar

$counter = $counter + 1


x : A variable

a : Either a variable or an integer constant

Assign        $x  = a
Add           $x += a   
Subract       $x -= a
Multiply      $x *= a
Divide        $x /= a
Remainder     $x %= a
And (binary)  $x &= a
Or (binary)   $x |= a
Xor (binary)  $x ^= a

Functions

Random

$x = Random a (Assigns $x a random value between 1..a inclusive, or 1 if a <= 1)

$x = Random 3      // Assigns $x either 1, 2, or 3
$y = 500
$x = Random $y     // Assigns $x a random value between 1 and the value of $y (e.g. 1..500)
$x = Random -50    // Assigns $x a value of 1


Comparison

Equal                  $x is a
Not Equal              $x is not a
Less Than              $x < a
Less Than or Equal     $x <= a
Greater Than           $x > a
Greater Than or Equal  $x >= a


Example

A loop that could be used to implement an off timer that increases in 5-minutes intervals. For example, another program could be written to increase $BathRoomLightCount by 1 each time an On button is pressed.


$BathRoomLightCount is an Integer Variable

If
       $BathRoomLightCount > 0
Then
       Wait  5 minutes
       $BathRoomLightCount -= 1
       Run Program 'Bathroom Timer' (If)
Else
  - No Actions - (To add one, press 'Action')

Related Pages

How-To Guide : Programs

Forum discussion:



ISY-26 INSTEON / ISY-99i Series INSTEON : User Guide : Program Tab : Variables Tab