Difference between revisions of "V2/CMS Tutorial/User Tools/Creating Content/Automation/Expression"
Elysia.Tan (talk | contribs) |
m (${<node_id>.location.<zone>} does not seem to work, and ${asset_3.location.level2} also seems to be an error.) |
||
(21 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<h1 class="main-heading">Add Expression</h1> | <h1 class="main-heading">Add Expression</h1> | ||
− | <div class="important">Note: Mandatory fields are marked with an ‘*’. The following steps assume that the user is already logged in. </div> | + | See [[V2/Concepts/Preparing_for_Expression_Creation|Pre-requisites for creating expressions]] for what you need before you can create expressions in Senfi. |
+ | |||
+ | This section covers the following topics: | ||
+ | * [[#Steps|General Steps]] | ||
+ | * [[#Construct Expression|Construct Expression]] | ||
+ | * [[#Configure Nodes|Configure Nodes]] | ||
+ | |||
+ | <div class="important">Note: Mandatory fields are marked with an ‘*’. The following steps assume that the user is already logged in to the [https://app.senfi.io/cms/ CMS]. </div> | ||
===Steps=== | ===Steps=== | ||
Line 13: | Line 20: | ||
# [[#Construct Expression|Construct Expression]]. | # [[#Construct Expression|Construct Expression]]. | ||
# Select '''SUBMIT''' (top right corner) to create the expression. | # Select '''SUBMIT''' (top right corner) to create the expression. | ||
+ | |||
+ | <div class="important">Note: When you are '''editing an existing expression''', deleting any connection between nodes will automatically disable the expression. </div> | ||
===Construct Expression=== | ===Construct Expression=== | ||
Line 39: | Line 48: | ||
# Attach an "Asset" node (input) to each "Metric". | # Attach an "Asset" node (input) to each "Metric". | ||
# Transform data using "[[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Expression/Node#Data Transformation|Data Transformation]]" nodes (if necessary). | # Transform data using "[[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Expression/Node#Data Transformation|Data Transformation]]" nodes (if necessary). | ||
− | # Create "Compare" and/or "Logic" nodes. | + | # Create "Compare" and/or "Logic" nodes. [[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Expression/Node#Logic|More information]] to construct the necessary logic. |
#* Logic graph should output a single Boolean (True/False) value. | #* Logic graph should output a single Boolean (True/False) value. | ||
#* "Compare" and "Logic" nodes can be nested. | #* "Compare" and "Logic" nodes can be nested. | ||
Line 48: | Line 57: | ||
[[File:Triggering_event.png|thumb|600px|center|event_3 is triggered when result changes from False to True <br> event_4 is triggered when result changes from True to False|link=]] | [[File:Triggering_event.png|thumb|600px|center|event_3 is triggered when result changes from False to True <br> event_4 is triggered when result changes from True to False|link=]] | ||
− | + | ===Configure Nodes=== | |
Each node contains attributes & options which you can modify. To modify the attributes of a node, simply '''select''' the node (in the working area). A window will popup to allow you to configure the node. | Each node contains attributes & options which you can modify. To modify the attributes of a node, simply '''select''' the node (in the working area). A window will popup to allow you to configure the node. | ||
− | ===== Aggregate | + | ====Metric node==== |
+ | Apart from the "Measurement" and "Metric" options, you can also modify the "Type" option. | ||
+ | |||
+ | Below explains the output of each "Type" option: | ||
+ | * '''Last-known value of (Default):''' Last known value of the metric. | ||
+ | * '''Range value of:''' Range of values associated with the metric. | ||
+ | ** This option accepts an additional "Start" and "End" (Optional) parameter | ||
+ | ** All values received within the "Start" and "End" timeframe will be returned. | ||
+ | ** The desired time unit (seconds, minutes, hours, days, values) can be changed by choosing from the [[File:Range_unit.png|100px|link=]] '''dropdown list'''. | ||
+ | |||
+ | <div class="important">Note: | ||
+ | * "Start" > "End". | ||
+ | * "Start" is inclusive but "End" is exclusive. | ||
+ | * If "End" is not specified, all values received in the past "Start" timeframe will be returned. </div> | ||
+ | |||
+ | ==== Aggregate Node ==== | ||
This section explains the output of each "Aggregate" node option. | This section explains the output of each "Aggregate" node option. | ||
− | * '''Sum:''' | + | * '''Sum:''' Sum of all input values. |
* '''Count:''' Number of input values. | * '''Count:''' Number of input values. | ||
* '''Average:''' Average of the input values. | * '''Average:''' Average of the input values. | ||
Line 64: | Line 88: | ||
* '''Percentile:''' [https://en.wikipedia.org/wiki/Percentile percentile]. | * '''Percentile:''' [https://en.wikipedia.org/wiki/Percentile percentile]. | ||
** This option accepts an additional "Percentile Value" parameter. | ** This option accepts an additional "Percentile Value" parameter. | ||
− | * '''Every:''' Outputs true if every input value fulfils the condition. | + | |
+ | <div class="important">Note: | ||
+ | It is advised to '''avoid''' using "Equal To" in the connected Compare Node, if the output of the Aggregate Node is not an Integer (i.e. Whole Number). </div> | ||
+ | |||
+ | * '''Every:''' Outputs '''true''' if every input value fulfils the condition. | ||
** This option accepts an additional "Condition" parameter. | ** This option accepts an additional "Condition" parameter. | ||
− | * '''Any:''' Outputs true if at least 1 input value fulfils the condition. | + | * '''Any:''' Outputs '''true''' if at least 1 input value fulfils the condition. |
** This option accepts an additional "Condition" parameter. | ** This option accepts an additional "Condition" parameter. | ||
− | ===== Function | + | <div class="important">Note: |
+ | If an Aggregate Node is used with the "Every" or "Any" option and it is the only input to a Compare Node, the value of the Compare Node should take one of the following forms: | ||
+ | * True/False | ||
+ | * TRUE/FALSE | ||
+ | * true/false </div> | ||
+ | |||
+ | ==== Function Node ==== | ||
This section explains the output of each "Function" node option. | This section explains the output of each "Function" node option. | ||
* '''Absolute value of:''' Absolute value of the input. | * '''Absolute value of:''' Absolute value of the input. | ||
Line 77: | Line 111: | ||
* '''Custom transformation (Map):''' Input transformed based on a custom mathematical expression. | * '''Custom transformation (Map):''' Input transformed based on a custom mathematical expression. | ||
** This option accepts an additional "mathematical operator" and "value" parameter to form a custom mathematical expression. | ** This option accepts an additional "mathematical operator" and "value" parameter to form a custom mathematical expression. | ||
+ | |||
+ | ====Event Node==== | ||
+ | This section explains how to retrieve values from expressions to be embedded in the event's [[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Event/Inputs|input]]: | ||
+ | * Input formula must begin with "${" and end with "}". | ||
+ | * Content enclosed within the brackets consist of 1 to 4 words, separated by ".". | ||
+ | ** '''General:''' ${<node_id>.<2nd word>.<3rd word>.<4th word>} | ||
+ | *** node_id is located at the '''top left corner''' of a node in the working area. [[File:Node_id.png|thumb|center|100px|node_id = asset_3|link=]] | ||
+ | ** 2nd to 4th word depend on the node type. | ||
+ | ** Supported node types: | ||
+ | *** [[#Embed Information of Asset Node Information|Asset]] | ||
+ | *** [[#Embed Information of All other Node types|Metric]] in single value mode | ||
+ | *** [[#Embed Information of All other Node types|Aggregate]] | ||
+ | *** [[#Embed Information of All other Node types|Function]] in single value mode | ||
+ | *** [[#Embed Information of All other Node types|Attribute]] | ||
+ | *** [[#Embed Information of All other Node types|Location]] | ||
+ | *** [[#Embed Information of All other Node types|Compare]] | ||
+ | *** [[#Embed Information of All other Node types|Logic]] | ||
+ | |||
+ | ====Embed Information of Asset Node Information==== | ||
+ | * '''Retrieve asset_id of asset:''' ${<node_id>} | ||
+ | ** E.g. ${asset_3} | ||
+ | * '''Retrieve value of metric:''' ${<node_id>.<measurement_code>.<metric_code>} | ||
+ | ** E.g. ${asset_3.temp_sensor.temp} | ||
+ | * '''Retrieve Zone id of asset:''' ${<node_id>.location.zone} | ||
+ | ** E.g. ${asset_3.location.zone} | ||
+ | * '''Retrieve attribute of asset:''' ${<node_id>.attribute.<attribute_name>[.<language_code>]} | ||
+ | ** If <language_code> is not specified, default language is used. | ||
+ | ** E.g. ${asset_3.attribute.model} | ||
+ | ** E.g. ${asset_3.attribute.model.ch} | ||
+ | |||
+ | ====Embed Information of All other Node types==== | ||
+ | * '''Retrieve value of the node:''' ${<node_id>} | ||
+ | ** E.g. ${compare_3} | ||
+ | |||
+ | <div class="important">Note: For nodes that '''do not''' contribute to the Expression evaluation, they will be considered '''non-existent''' in the Event description. </div> |
Latest revision as of 17:39, 4 November 2022
Contents
Add Expression
See Pre-requisites for creating expressions for what you need before you can create expressions in Senfi.
This section covers the following topics:
Steps
- Go to the Automation tab.
- Select the EXPRESSION tab and then ADD NEW.
- Fill in Name of the Expression.
- Set the Type of the Expression by choosing from the Type dropdown list.
- Immediate (Default): Expression is checked when new values are received for any of the selected Input Measurement.
- Polling: Expression is checked periodically regardless of whether there are new values for any of the selected Input Measurement.
- Choose to enable or disable the expression.
- Construct Expression.
- Select SUBMIT (top right corner) to create the expression.
Construct Expression
This section will guide you on how to construct an expression using the EXPRESSION EDITOR when adding an expression in the CMS. The goal here is to tell Senfi how to detect an event that you want to be notified of/should be responded to.
The Expression Editor is a graph-based Drag & Drop editor.
Arrows coming in from the left of a node indicate its input and those going out from its right indicate its output.
Each Node falls into one of the following categories:
- Asset Identifier
- Input
- Data Transformation
- Logic
- Result
- Event
Data originates from Metric nodes, is transformed by Data Transformation and/or Logic nodes, and eventually consumed by Result & Event nodes.
See Node Type for more information about each Node Type.
Steps
- Create "Metric" nodes, one for each Input metric.
- Attach an "Asset" node (input) to each "Metric".
- Transform data using "Data Transformation" nodes (if necessary).
- Create "Compare" and/or "Logic" nodes. More information to construct the necessary logic.
- Logic graph should output a single Boolean (True/False) value.
- "Compare" and "Logic" nodes can be nested.
- More than 2 inputs can be attached to each "Logic" node.
- Attach output of Logic graph to the "Result" node.
- Create "Event" nodes, one for each desired Event.
- Attach the "Result" node (input) to each "Event" node.
Configure Nodes
Each node contains attributes & options which you can modify. To modify the attributes of a node, simply select the node (in the working area). A window will popup to allow you to configure the node.
Metric node
Apart from the "Measurement" and "Metric" options, you can also modify the "Type" option.
Below explains the output of each "Type" option:
- Last-known value of (Default): Last known value of the metric.
-
Range value of: Range of values associated with the metric.
- This option accepts an additional "Start" and "End" (Optional) parameter
- All values received within the "Start" and "End" timeframe will be returned.
- The desired time unit (seconds, minutes, hours, days, values) can be changed by choosing from the dropdown list.
- "Start" > "End".
- "Start" is inclusive but "End" is exclusive.
- If "End" is not specified, all values received in the past "Start" timeframe will be returned.
Aggregate Node
This section explains the output of each "Aggregate" node option.
- Sum: Sum of all input values.
- Count: Number of input values.
- Average: Average of the input values.
- Median: Median value of the input values.
- Max: Largest input value.
- Min: Smallest input value.
- Mode: Input value that appears most often.
- Range: Difference between the largest and smallest input value (max - min).
- Stddev: standard deviation
-
Percentile: percentile.
- This option accepts an additional "Percentile Value" parameter.
-
Every: Outputs true if every input value fulfils the condition.
- This option accepts an additional "Condition" parameter.
-
Any: Outputs true if at least 1 input value fulfils the condition.
- This option accepts an additional "Condition" parameter.
If an Aggregate Node is used with the "Every" or "Any" option and it is the only input to a Compare Node, the value of the Compare Node should take one of the following forms:
- True/False
- TRUE/FALSE
- true/false
Function Node
This section explains the output of each "Function" node option.
- Absolute value of: Absolute value of the input.
- Round to nearest integer: Input rounded to the nearest integer.
- Round up: Input rounded up.
- Round down: Input rounded down.
-
Custom transformation (Map): Input transformed based on a custom mathematical expression.
- This option accepts an additional "mathematical operator" and "value" parameter to form a custom mathematical expression.
Event Node
This section explains how to retrieve values from expressions to be embedded in the event's input:
- Input formula must begin with "${" and end with "}".
- Content enclosed within the brackets consist of 1 to 4 words, separated by ".".
Embed Information of Asset Node Information
-
Retrieve asset_id of asset: ${<node_id>}
- E.g. ${asset_3}
-
Retrieve value of metric: ${<node_id>.<measurement_code>.<metric_code>}
- E.g. ${asset_3.temp_sensor.temp}
-
Retrieve Zone id of asset: ${<node_id>.location.zone}
- E.g. ${asset_3.location.zone}
-
Retrieve attribute of asset: ${<node_id>.attribute.<attribute_name>[.<language_code>]}
- If <language_code> is not specified, default language is used.
- E.g. ${asset_3.attribute.model}
- E.g. ${asset_3.attribute.model.ch}
Embed Information of All other Node types
-
Retrieve value of the node: ${<node_id>}
- E.g. ${compare_3}