« Back to Product

Documentation

Action Scripts

Action scripts are scripts that are called when a Variable is clicked in a Visualization (e.g., WebFront, Mobile).
The action script needs to be linked to the corresponding variable as "Custom Action".
Special variables for called scripts are shown in System Variables.
An action script can be used by multiple variables. The most common variant is shown below: "Set Variable only".

Select Action Script

The selection of an action script is the same as the selection of a Variable Action .

Warning

Some variables of added modules contain a "Default Action". It can be overwritten by a "Custom Action".

Selecting an Action Script

Create Action Script

An action script is a regular script file. It becomes an action script by linking it to a variable.
An action script should describe the switching process or at least a command that sets the variable to the requested state:

Example 1

//Set Variable only
    SetValue($_IPS['VARIABLE'], $_IPS['VALUE']);

Example 2

//Set variable accordingly when switching was sucessful
    if (FS20_SwitchMode(12345, (boolean)$_IPS['VALUE'])) {
        SetValue($_IPS['VARIABLE'], $_IPS['VALUE']);
    }
Content of an Action Script

Bad Action Scripts

Some criterias should be regarded when creating an action script. Otherwise, unexpected behavior could appear.

Setting a Variable without Checking for Sucessful Switching

Most functions return a "True" when they succeed. This should be checked.
If this is not done, the state of IP-Symcon and the device are not consistent any more. Thus, the configured automatic control could fail.

//Variable is set to new value even if the switching was not sucessful. 
    //This can lead to consistency faults.
    FS20_SwitchMode(12345, (boolean)$_IPS['VALUE']);
    SetValue($_IPS['VARIABLE'], $_IPS['VALUE']);

Switching a Device via Event when the Variable changes

There should be no additional event to switch a device after the corresponding variable was changed. This approach cannot detect switching problems of the device. Thus, error messages are hidden and the variable value could be different from the device value.
Consider a dimmer that is set from 0% to 50% via WebFront.
The variable is instantly set to 50% und the switch command is executed asynchonously by the additional event. The action script cannot detect if the switch command failed and the variable within IP-Symcon stays at 50% even though the device value is 0%.

Never use an Event to Switch Devices
Any questions?