Documentation
RequestActionColor
bool RequestActionColor (int $VariableID, int $ColorValue)
Parameters
| VariableID | ID of the variable |
| ColorValue | Color in the format 0xRRGGBB |
Returns
If the function succeeds, it returns TRUE, otherwise FALSE.
Description
The function executes the action of the variable with the ID VariableID with the color ColorValue (format 0xRRGGBB). It behaves like RequestAction, but first converts ColorValue into the format of the variable - exactly like SetValueColor:
- Integer variables: ColorValue is passed to the action unchanged.
- String variables with the presentation Color: the JSON object according to the parameter ENCODING of the presentation is passed to the action (RGB, CMYK, HSV, HSL or xy, see constants
COLOR_ENCODING_*; the fields are described at SetValueColor).
The custom action of the variable is executed (e.g. an action script set via IPS_SetVariableCustomAction), otherwise the default action, usually the one of the parent instance. In the action script, $_IPS['SENDER'] = "Action" is available and $_IPS['VALUE'] contains the converted value. Unlike SetValueColor, the device is switched; whether and when the value of the variable is updated is up to the action.
The conversion happens before the action is executed: if a string variable does not use the presentation Color, the function fails with "Variable does not use presentation Color". For an unknown encoding it fails with "Invalid Color Encoding" without executing the action; for variables of type Boolean or Float with "Invalid Variable Type". If the variable has neither a custom nor a default action, it fails with "No valid action available".
Example
// Switch the lamp to green
RequestActionColor(12345, 0x00FF00);