« Back to Product

Documentation

IPS_GetVariable

 array IPS_GetVariable (int $VariableID) 

Parameters

VariableID

ID of the variable

Returns

The following information is available as key => value pairs:

Index Type Description
VariableAction integer ID of the instance that is notified about desired changes to the variable. 0 for none or deactivated connection
VariableChanged float Unix timestamp of the most recent variable change
VariableCustomAction integer ID of the script that starts on desired changes to the variable from the visualization. If an existing default action is disabled, the non-existent ScriptID 1 is given. (Since version 2.5 # 2300)
VariableCustomProfile string Name of the user defined profile. Empty if no profile is specified
VariableID integer ID of the variable
VariableIsLocked boolean Indicates if the variable is above the variable limit and thus cannot be written (Available since Version 2.3)
VariableProfile string Name of the system profile. Empty if no profile is specified
VariableType (since 4.0) integer Type of the variable (0: Boolean, 1: Integer, 2: Float, 3: String)
VariableUpdated float Unix timestamp of the most recent variable update
VariableValue (until 3.4) array see table Variable Value (replaced by VariableType and GetValue)

Table: Variable value

Index Type Description
ValueType integer Type of the variable (0: Boolean, 1: Integer, 2: Float, 3: String)
ValueBoolean boolean Value of the variable depending on ValueType
ValueInteger integer Value of the variable depending on ValueType
ValueFloat float Value of the variable depending on ValueType
ValueString string   Value of the variable depending on ValueType

Description

This function returns an array that contains information about the variable with the ID VariableID.

Warning

The value of a variable is get with the function GetValue since version 4.0

Warning

The functionality until version 3.4 is provided by the function "array IPS_GetVariableCompatibility(integer $VariableID)" since version 4.0.

Example

// Since version 4.0
print_r(IPS_GetVariable(40770)); 
/* Examplary output:
Array
(
    [VariableChanged] => 1246039629
    [VariableCustomAction] => 0
    [VariableCustomProfile] => BoolProfile
    [VariableID] => 40770
    [VariableIsLocked] =>
    [VariableProfile] => ~Switch
    [VariableType] => 0
    [VariableUpdated] => 1246039629
)
*/
 
print_r(IPS_GetVariableCompatibility(40770));
/* Examplary output:
Array
(
    [VariableChanged] => 1246039629
    [VariableCustomAction] => 0
    [VariableCustomProfile] => BoolProfile
    [VariableID] => 40770
    [VariableIsLocked] =>
    [VariableProfile] => ~Switch
    [VariableUpdated] => 1246039629
    [VariableValue] => Array
    (
        [ValueArray] => Array
        (
        )
 
        [ValueBoolean] => 1
        [ValueFloat] => 0
        [ValueIndex] => Array
        (
            [IndexInt] => 0
            [IndexStr] =>
            [IndexType] => 0
        )
 
        [ValueInteger] => 0
        [ValueString] =>
        [ValueType] => 0
    )
)
*/
 
// Until version 3.4
print_r(IPS_GetVariable(40770));
/* Exemplary output:
Array
(
    [VariableChanged] => 1246039629
    [VariableCustomAction] => 0
    [VariableCustomProfile] => BoolProfile
    [VariableID] => 40770
    [VariableIsLocked] =>
    [VariableProfile] => ~Switch
    [VariableUpdated] => 1246039629
    [VariableValue] => Array
    (
        [ValueArray] => Array
        (
        )
 
        [ValueBoolean] => 1
        [ValueFloat] => 0
        [ValueIndex] => Array
        (
            [IndexInt] => 0
            [IndexStr] =>
            [IndexType] => 0
        )
 
        [ValueInteger] => 0
        [ValueString] =>
        [ValueType] => 0
    )
)
*/
Any questions?