Operations
In this section it is possible set predefined actions to execute by:
-
pressing the execution button in the section, in the context menu of the object/link, or on the widget,
-
trigger (see actions on state changes).
Execution event and operation result are saved to the Operations history. |
Operations can be used to:
-
change state of an object or a link,
-
change object parameters or link parameters,
-
obtain data from an object (parameters, configuration, software version etc),
-
upload software updates to an object.
It is possible to add a set of default operations to an object class in the System configuration window.
This section is available only for users with permissions to run operations. Only users with permissions to manage operations can add, edit and delete operations. |
Control buttons:
| execute operation;
| change operation;
| delete operation.
Click the button to create a new operation.
There are two operation types, the fields depend on the selected type:
-
Program / script execution runs executable file.
-
MQTT message sends a message using the MQTT protocol.
Fields description:
Field | Description in program / script | Description in MQTT | ||
---|---|---|---|---|
Name |
Operation name displayed in the web interface. |
|||
Type |
Dropdown list with available operation types. |
|||
Subtype |
Dropdown list with available subtypes:
|
|||
Arguments |
Dropdown list where arguments the script will be executed with are specified. |
|||
Topic |
MQTT topic to send message. |
|||
Message |
MQTT message text. |
|||
Description |
Explanation to the operation. |
|||
Show results in popup message |
If the toggle is set to YES, the execution result will be displayed in a popup. The following is specified in the message:
Click the button or refresh the page to close the popup.
|
The following variables can be used in operations:
-
{{id}}
– ID of the object, in which the operation is executed; -
{{properties.property_name}}
– property value of the object, in which the operation is executed (the name of the property is specified in the variable); -
{{jobId}}
– ID of the executed operation;The identifier is unique for each execution, details are in the REST-API documentation. -
{{user.id}}
– ID of the user, who has executed the operation; -
{{user.login}}
– login of the user, who has executed the operation.
The variables can be used in:
-
the topic and the message of the operation type MQTT message;
-
the script of the operation type Program/script execution - Script with text.
Ask users to set operation arguments
Before executing an operation, you can ask users to input an argument that will be passed to the operation’s script. To do this, add the {{ask.argument_name}}
to the script.
For the operation of "Program/script in file system" and "Script from repository" subtypes, you can only add this macro in the "Arguments" list. For the "Script with text" subtypes, you can add {{ask.argument_name}}
macro either to the script’s source text or to the list of arguments.
This functionality works only for "Program / script execution" operations. If you try to use this feature in operations of "MQTT Message" type, the {{ask.argument_name}} macro will be replace by an empty string.
|
For example, the following operation will ask a user that manually executes it for the values of packets_count
and ip_address
variables:
#!/bin/bash
ping -c {{ask.packets_count}} {{ask.ip_address}}
When a user executes this operation, the system will prompt them to enter values of the packets_count
and ip_address
arguments:
You can use this macro in the "Arguments" list as well:
The example above has to be modified to handle arguments from "Arguments" list:
#!/bin/bash
ping -c "$1" "$2"