Operations

In this section it is possible set predefined actions to execute by:

Execution event and operation result are saved to the Operations history.
image

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.

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:

image | execute operation;

image | change operation;

image | delete operation.

Click the image button to create a new operation.

There are two operation types, the fields depend on the selected type:

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:

  • Program/script in file system – previously created file stored on the server.

    • The name or the full path to the script is specified.

  • Script from repository - script created and added to the system repository earlier.

    • The script can be selected from the drop-down list.

  • Script with text - manual script input.

    • The script text must be entered.

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:

  • operation name,

  • path to the object in the hierarchy,

  • result of the execution.

image

Click the image button or refresh the page to close the popup.

The popup window is available only for those operations that are executed manually. Results of operations, performed by triggers, are not displayed.

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:

argument prompt

You can use this macro in the "Arguments" list as well:

arguments list ask

The example above has to be modified to handle arguments from "Arguments" list:

#!/bin/bash

ping -c "$1" "$2"