In the Action Configuration View, you can write programs that are executed by triggers. These programs are called “Actions.”
In a typical use case, sensor data triggers multiple actions and passes multiple parameters to those actions.
To create or edit an action, follow these steps:
To create a new action:
NewAction.acs
)In the action editor, actions are composed of “steps” that are arranged from left to right in the execution sequence.
To add a new step:
The following types of variables can be used within action programs:
ap.
av.
cp.
Method
(GET/POST etc.) and URL
cv.
cv.StatusCode
(HTTP status code in HTTPRequest component)tv.
tv.AreaId
: Area IDtv.AreaName
: Area nametv.LayerId
: Layer IDtv.LayerName
: Layer nametv.KindId
: Data type IDtv.KindName
: Data type nametv.PhysicalDeviceId
: Sensor’s physical device IDtv.PhysicalDeviceName
: Sensor’s physical device nametv.Timestamp
: Time when data was output from sensor (RFC3339Nano format)tv.DataId
: Unique ID for this sensor datatv.Data
: Sensor data value (same as cv.Payload
of the first component)tp.
tp.KeyAreaName
, tp.KeyLayerName
, tp.TriggerName
Available variable types are:
Variable Type | Description |
---|---|
Int | Integer |
Double | Floating point |
String | String |
Bool | true/false |
DateTime | Date and time |
Byte array | Byte array |
Array | Array |
Object | Object |
Conversion between types is possible. Conversion rules are defined as follows:
The following operators can be used in action programs:
Arithmetic Operators:
+
Addition-
Subtraction*
Multiplication/
Division**
Power&
Bitwise AND|
Bitwise OR^
Bitwise XOR%
ModuloComparison Operators:
>
Greater than>=
Greater than or equal<
Less than<=
Less than or equal==
Equal!=
Not equal=~
Regular expression match!~
Regular expression non-matchLogical Operators:
||
Logical OR&&
Logical ANDWhen referencing Object type variable values in actions, use dot notation or bracket notation.
For example, with JSON data like this:
{
"id": "XXXXXX",
"source": {
"channel": 4,
"bacId": "YYYYYY"
},
"common": {
"description": "Face Recognition",
"time": "2019-06-17T07:53:22.986Z"
},
"fr": {
"candidates": [
{
"customId": "00001",
"displayName": "Person B",
"similiarityScore": "0.7272"
}
]
}
}
To reference fr.candidates[0].displayName
, use either:
tv.Data.fr.candidates[0].displayName
Or, when key names contain spaces or hyphens:
tv.Data["fr"]["candidates"][0]["displayName"]
tv.Data.fr.candidates[0]["display Name"] // For key names containing spaces
These access methods can also be used in action conditions:
cv.Payload.fr.candidates[0].displayName == "Person B"
They can also be used in trigger conditions. For example, to trigger an action only for males in IVAR:
tv.Data.iod.gender == "MALE"
Action components provide component variables for input payload (cv.Payload
) and output payload (cv.Payload
).
tv.Data
) becomes the input payload (cv.Payload
)When selecting a component in the Action Editor screen, the Pre Mappings / Post Mappings editing area appears on the right.
cp.Color = "Blue"
Expressions can include:
The evaluation result type of the right-hand expression is automatically converted to the left-hand type.
You can also use comparison operators to return boolean values:
cv.Payload > 10
cv.Payload == "abc"
Functions available in Pre Mappings / Post Mappings expressions:
String Functions:
Len
, Contains
, RuneCount
, HasPrefix
, HasSuffix
, Index
, Join
, LastIndex
, Repeat
, Replace
, Split
, ToLower
, ToUpper
, Trim
, TrimLeft
, TrimRight
, TrimPrefix
, TrimSuffix
Type Conversion Functions:
ToBool
, ToInt
, ToFloat
, ToString
, ToDate
, ToBinary
, ToJSON
Encoding Functions:
URLPathEscape
, URLPathUnescape
, URLQueryEscape
, URLQueryUnescape
, MD5
, SHA1
, SHA256
, BASE64
, DecodeBASE64
, BASE64URL
, DecodeBASE64URL
Date Functions:
Now
, Year
, Month
, Day
, Hour
, Minute
, Second
, Weekday
, ToLocal
, ToUTC
, ToTimezone
, DateFormat
, DateParse
Environment Variables:
Env
Regular Expression Functions:
RegExpMatch
, RegExpFind
, RegExpFindSubmatch
, RegExpFindAll
, RegExpReplace
, UUID
You can output debug logs by pressing the button in the top left of the component. Debug logs display the values of tp/tv/ap/av/cp/cv properties and variables.
Action programs are processed in the following order:
When debug log function is ON, variable contents after step 3 (PreMappings evaluation and assignment) are output. This allows you to check variable states at each step.
Note that while components normally operate independently in parallel, when executing actions with debug log output, synchronous processing occurs in the action engine.
Files specified in component properties can use various file path formats. Here’s how to write paths for different cases.
The default location varies by OS:
For non-Windows
File Path | Description |
---|---|
sample.txt | Specifies sample.txt in actmgr/data folder |
./sample.txt | Specifies sample.txt in actmgr/data folder |
For Windows
File Path | Description |
---|---|
sample.txt | Specifies sample.txt in actmgr/data folder |
.\sample.txt | Specifies sample.txt in actmgr/data folder |
For non-Windows
File Path | Description |
---|---|
../../../../gravio/sample.txt | Specifies gravio/sample.txt 4 levels up from actmgr/data folder |
For Windows
File Path | Description |
---|---|
..\..\..\..\gravio/sample.txt | Specifies gravio\sample.txt 4 levels up from actmgr/data folder |
For non-Windows
File Path | Description |
---|---|
/home/gravio/sample.txt | Specifies home/gravio/sample.txt under root |
For Windows
File Path | Description |
---|---|
c:\temp\sample.txt | Specifies temp\sample.txt under c: drive |
Note: These examples assume reading a sample.txt file.
Some action components, such as email sending and HTTP sending, handle attachments. Here’s how to specify attachments.
Multiple files can be specified as attachments. File path notation differs by OS environment, so follow these guidelines.
In Windows, actmgr\data
is automatically stored in file paths. Path specification is also possible.
Note: When folder or file names contain spaces, they must be enclosed in "
(double quotes).
Basic Examples:
image.jpg
subfolder\image.jpg
"subfolder 2021\image.jpg"
Absolute Path Examples:
c:\image.jpg
Multiple Files and Wildcards:
You can specify multiple files and use wildcards. Use ;
(semicolon) as separator for multiple files and *
(asterisk) for wildcards.
image.jpg;image2.jpg
subfolder\*.jpg
image.jpg;image2.jpg;subfolder\*.jpg
In Unix-based systems, actmgr/data
is automatically stored in file paths. Path specification is also possible.
Note: When folder or file names contain spaces, they must be enclosed in "
(double quotes).
Basic Examples:
image.jpg
subfolder/image.jpg
"subfolder 2021/image.jpg"
Absolute Path Examples:
/home/username/image.jpg
Multiple Files and Wildcards:
You can specify multiple files and use wildcards. Use ;
(semicolon) as separator for multiple files and *
(asterisk) for wildcards.
image.jpg;image2.jpg
subfolder/*.jpg
image.jpg;image2.jpg;subfolder/*.jpg
By using the correct path separators and file specification methods for your OS environment, you can properly specify attachments. Remember to always enclose paths containing spaces in double quotes.