Difference between revisions of "V2/CMS Tutorial/User Tools/Creating Content/Automation/Event/Inputs"

From Senfi Docs
Jump to: navigation, search
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<h1 class="main-heading">Event Inputs</h1>
 
<h1 class="main-heading">Event Inputs</h1>
  
Event inputs are used to pass "variables"/"messages" from a triggered [[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Expression|expression]] to the [[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Event|event]], and on to the event's [[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Event/Action|action]]/[[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Alarm|alarm]].
+
Event inputs are used to pass information from a triggered [[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Expression|expression]] to the [[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Event|event]], and on to the event's [[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Event/Action|action]]/[[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Alarm|alarm]].
  
The following can be embedded:
+
This section explains how the [[#Embed Formula|embed formula]] is used to embed an event's input values into its description and action's content.
* [[#Embed value & tag|Embed value/tag of an Input Metric]]
 
* [[#Embed Event Name|Embed event name]]
 
* [[#Embed User-Defined Input|Embed User-Defined Input]]
 
* [[#Embed Event Description|Embed event description]]
 
  
===Embed value & tag===
+
See [[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Expression#Event Node|Embed Node Information]] to learn how to pass information from a triggered expression to the event inputs.
You can embed the value or tag of an Input metric in the message of an [[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Event/Action|event action]]/[[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Event/Description|event description]].
 
  
To embed:
+
===Embed Formula===
* metric's value, use <tt>${<measurement_code>.<metric_code>}</tt>. e.g: <tt>${iot_temperature_sensor_v1.temperature}</tt>
+
* Input formula must begin with "${" and end with "}".  
* metric's tag, use <tt>${<measurement_code>.<tag>}</tt>. e.g: <tt>${iot_temperature_sensor_v1.site_id}</tt>
+
* Content enclosed within the brackets consist of 1 to 2 words, separated by ".".
 +
** '''General:''' ${<input_name>.<2nd word>}
 +
** input_name refers to [[#User-defined Input|user-defined inputs]]
 +
** 2nd_word is used to [[#Format Values|format]] the embedded value
  
===Embed Event Name===
+
===User-defined Input===
You can embed the name of an event in the message of an [[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Event/Action|event action]]/[[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Event/Description|event description]].
+
# Fill in the "Inputs" field.
 +
# Select the user-defined input you want to embed.
 +
#* They are shown in the [[File:User_defined_input.png|160px|link=]] '''Click to embed input''' field (under the message of an event's action/event's description box).
  
To embed:
+
===Format Values===
* Event's name, use <tt>${name}</tt>.
+
The CMS supports two types of formatting:
 +
* [[#Round|Round values]]
 +
* [[#Format Date|Format date]]
  
===Embed User-Defined Input===
+
====Round====
You can embed the user-defined inputs in the message of an [[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Event/Action|event action]]/[[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Event/Description|event description]].
+
<div class="important">Note:Value of <input_name> must be a '''number'''.</div>
  
To embed:
+
* '''Round values to nearest integer:''' ${<input_name>.round()}
# Key the user-defined input into the '''Inputs''' field under the '''GENERAL INFORMATION''' tab of the event.
+
* E.g. ${asset_id.round()}
# Select the user-defined input which will be shown in the [[File:User_defined_input.png|160px|link=]] '''Click to embed input''' field (under the message of an event action/event description box).
 
  
===Embed Event Description===
+
====Format Date====
You can embed the description of an event in the message of an [[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Event/Action|event action]]/[[V2/CMS_Tutorial/User_Tools/Creating_Content/Automation/Event/Description|event description]].
+
<div class="important">Note:Value of <input_name> must be a '''datetime'''.</div>
  
To embed:
+
Dates are parsed using Moment in UTC mode. Refer to [https://momentjs.com/docs/#/parsing/ docs] here.
* Event's description, use <tt>${description}</tt>.
+
 
 +
You can format dates using:
 +
* '''Organization's default date-time & UTC offset''': ${<input_name>.to_date_str()}
 +
** E.g. {date_of_incident.to_date_str()}
 +
* '''Specified <preset> format & organization's default UTC offset''': ${<input_name>.to_date_str(<preset>)}
 +
** E.g. ${date_of_incident.to_date_str(iso)}
 +
* '''Specified <preset> format & <utc_offset>''': ${<input_name>.to_date_str(<preset> <utc_offset>)}
 +
** E.g. ${date_of_incident.to_date_str(iso -10)} or ${date_of_incident.to_date_str(iso +10)}
 +
* '''Specified <format> & <utc_offset>''': ${<input_name>.to_date_str(<format> <utc_offset>)}
 +
** E.g. ${date_of_incident.to_date_str(MM/DD/YYYY -10)} or ${date_of_incident.to_date_str(MM/DD/YYYY HH:mm +10)}
 +
 
 +
<div class="important">Note:
 +
* For <utc_offset> only the first two digits will be considered.
 +
* For <format>, "HH" refers to hours in a day (24-hour clock) and "hh" refers to hours in am/pm format (12-hour clock). </div>
 +
 
 +
====List of available presets====
 +
{| class="wikitable"
 +
|-
 +
|
 +
|'''Preset'''
 +
|'''Equivalent Format'''
 +
|'''Sample Output'''
 +
|-
 +
|rowspan="4"|'''ISO (Year first)'''
 +
|iso
 +
|rowspan="2"|YYYY-MM-DDTHH:mm:ssZ
 +
|rowspan="2"|1997-07-16T19:20:30+01:00
 +
|-
 +
|year_first
 +
|-
 +
|iso_date
 +
|rowspan="2"|YYYY-MM-DDZ
 +
|rowspan="2"|1997-07-16+08:00
 +
|-
 +
|year_first_date
 +
|-
 +
|rowspan="2"|'''Day first'''
 +
|day_first
 +
|DD-MM-YYYYTHH:mm:ssZ
 +
|16-07-1997T19:20:30+01:00
 +
|-
 +
|day_first_date
 +
|DD-MM-YYYYZ
 +
|16-07-1997+01:00
 +
|-
 +
|rowspan="2"|'''Month first'''
 +
|month_first
 +
|MM-DD-YYYYTHH:mm:ssZ
 +
|07-16-1997T19:20:30+01:00
 +
|-
 +
|month_first_date
 +
|MM-DD-YYYYZ
 +
|07-16-1997+01:00
 +
|-
 +
|'''Time'''
 +
|time
 +
|THH:mm:ssZ
 +
|T19:20:30+01:00
 +
|-
 +
|rowspan="2"|'''Unix'''
 +
|unix
 +
|X
 +
|1360013296
 +
|-
 +
|unix_ms
 +
|x
 +
|1360013296123
 +
|}

Latest revision as of 17:11, 12 July 2021

Event Inputs

Event inputs are used to pass information from a triggered expression to the event, and on to the event's action/alarm.

This section explains how the embed formula is used to embed an event's input values into its description and action's content.

See Embed Node Information to learn how to pass information from a triggered expression to the event inputs.

Embed Formula

  • Input formula must begin with "${" and end with "}".
  • Content enclosed within the brackets consist of 1 to 2 words, separated by ".".

User-defined Input

  1. Fill in the "Inputs" field.
  2. Select the user-defined input you want to embed.
    • They are shown in the User defined input.pngClick to embed input field (under the message of an event's action/event's description box).

Format Values

The CMS supports two types of formatting:

Round

Note:Value of <input_name> must be a number.
  • Round values to nearest integer: ${<input_name>.round()}
  • E.g. ${asset_id.round()}

Format Date

Note:Value of <input_name> must be a datetime.

Dates are parsed using Moment in UTC mode. Refer to docs here.

You can format dates using:

  • Organization's default date-time & UTC offset: ${<input_name>.to_date_str()}
    • E.g. {date_of_incident.to_date_str()}
  • Specified <preset> format & organization's default UTC offset: ${<input_name>.to_date_str(<preset>)}
    • E.g. ${date_of_incident.to_date_str(iso)}
  • Specified <preset> format & <utc_offset>: ${<input_name>.to_date_str(<preset> <utc_offset>)}
    • E.g. ${date_of_incident.to_date_str(iso -10)} or ${date_of_incident.to_date_str(iso +10)}
  • Specified <format> & <utc_offset>: ${<input_name>.to_date_str(<format> <utc_offset>)}
    • E.g. ${date_of_incident.to_date_str(MM/DD/YYYY -10)} or ${date_of_incident.to_date_str(MM/DD/YYYY HH:mm +10)}
Note:
  • For <utc_offset> only the first two digits will be considered.
  • For <format>, "HH" refers to hours in a day (24-hour clock) and "hh" refers to hours in am/pm format (12-hour clock).

List of available presets

Preset Equivalent Format Sample Output
ISO (Year first) iso YYYY-MM-DDTHH:mm:ssZ 1997-07-16T19:20:30+01:00
year_first
iso_date YYYY-MM-DDZ 1997-07-16+08:00
year_first_date
Day first day_first DD-MM-YYYYTHH:mm:ssZ 16-07-1997T19:20:30+01:00
day_first_date DD-MM-YYYYZ 16-07-1997+01:00
Month first month_first MM-DD-YYYYTHH:mm:ssZ 07-16-1997T19:20:30+01:00
month_first_date MM-DD-YYYYZ 07-16-1997+01:00
Time time THH:mm:ssZ T19:20:30+01:00
Unix unix X 1360013296
unix_ms x 1360013296123