Technical Reference

How to reference Object type variables in Actions

When referring to Object type variables in actions, you can access elements using dot notation or square brackets.

Example JSON data from IVAR face recognition:

{

"id":"XXXXXX",

"source":{

"channel":4,

"bacId" : "YYYYYY",

"taskId" : "ZZZZZZ",

"ivarId" : "000000"

},

"common":{

"description":"Face Recognition",

"presentImageTime":"2019-06-17T07:53:22.986Z",

"time":"2019-06-17T07:53:22.986Z",

"type":"FR"

},

"iod":{

"age":"MIDDLE",

"ageRange":[38, 53],

"faceAvailable":true,

"frSuitable":"NA",

"gender":"MALE",

"glasses":"REGULAR",

"groupId":0,

"liveness":"NO_RESULT",

"livenessProbability":"0.0000",

"mask":"NA",

"objectId":649,

"objectType":"FACE",

"occlusion":"NA",

"race":"NA"

},

"fr":{

"candidates":[{

"customId":"00001",

"displayName":"Person B",

"id":"6",

"indentityGroup":"Company A",

"similiarityScore":"0.7272"

}],

"fdrVersion":"60032084",

"indentityGroup":"Set2",

"mmsReturn":"OK"

}

}

To reference fr → candidates → displayName:

tv.Data.fr.candidates[0].displayName

Alternative syntax for keys with spaces:

tv.Data["fr"]["candidates"][0]["display Name"]

tv.Data.fr.candidates[0]["display Name"]

Use in conditions:

cv.Payload.fr.candidates[0].displayName == "Person B"

tv.Data.iod.gender == "MALE"

String Functions

Available string manipulation functions:

FunctionArgumentsDescriptionExample
LenLen(s)Returns length (bytes) of stringLen("abc012漢字") → 11
ContainsContains(s, substr)Returns true if s contains substrContains("abc012漢字", "漢字") → true
RuneCountRuneCount(s)Returns character countRuneCount("abc012漢字") → 8
HasPrefixHasPrefix(s, prefix)Returns true if s starts with prefixHasPrefix("https://www.asteria.com/", "https://") → true
HasSuffixHasSuffix(s, suffix)Returns true if s ends with suffix
FirstIndexFirstIndex(s, substr)Returns first occurrence positionFirstIndex("abc012漢字", "漢字") → 6
JoinJoin(a, sep)Joins array elements with separatorJoin(["abc","def"], "-") → "abc-def"
ReplaceReplace(s, old, new[, n])Replaces old with new n times
SplitSplit(s, sep[, n])Splits string by separatorSplit("a,b,c", ",") → ["a", "b", "c"]
ToLowerToLower(s)Converts to lowercase
ToUpperToUpper(s)Converts to uppercase
TrimTrim(s[, cutset])Removes characters from both endsTrim(" abc ") → "abc"
SprintfSprintf(format, s)Formats string with placeholdersSprintf("Count: %d", ToInt(cv.Payload))
JSONPathJSONPath(path, s)Extracts value using JSONPathJSONPath("$.store.book[*].author", cv.Payload)
IFSIFS (condition1, value1[, ...])Evaluates conditions in orderIFS (ToFloat(cv.Payload) >= 10, "10 or more", true, "Less than 10")

Sprintf Usage

Formats strings with specified format specifiers.

SpecifierDescription
%bBinary integer
%dDecimal integer
%x %XHexadecimal
%e %EScientific notation
%f %FFloating point
%g %GCompact floating point
%sString
%%Literal %

Examples

Sprintf("Message count: %d", ToInt(cv.Payload))

Sprintf("Value: %.2f", cv.Payload)

Regular Expression Functions

Available regular expression functions:

FunctionArgumentsDescriptionExample
RegExpMatchRegExpMatch(re, s)Returns true if pattern matchesRegExpMatch("G.*o", "Gravio HubKit") → true
RegExpFindRegExpFind(re, s)Returns first matchRegExpFind("i.", "Gravio HubKit") → "io"
RegExpFindSubmatchRegExpFindSubmatch(re, s)Returns match with subgroupsRegExpFindSubmatch("(G.*o) (H.*t)", "Gravio HubKit") → ["Gravio HubKit", "Gravio", "HubKit"]
RegExpFindAllRegExpFindAll(re, s[, n])Returns all matchesRegExpFindAll("i.", "Gravio HubKit") → ["io", "it"]
RegExpReplaceRegExpReplace(re, s, repl)Replaces matches with replacement
UUIDUUID([sep])Generates UUID string

JSONPath() Usage Examples

JSONPath can be used to extract values from JSON data.

Sample Data

{ "store": {

"book": [

{ "category": "reference",

"author": "Nigel Rees",

"title": "Sayings of the Century",

"price": 8.95

},

{ "category": "fiction",

"author": "Evelyn Waugh",

"title": "Sword of Honour",

"price": 12.99

}

],

"bicycle": {

"color": "red",

"price": 19.95

}

}

}

Example usage:

JSONPath("$.store.bicycle.color", cv.Payload) → "red"

JSONPath("$.store.book[*].author", cv.Payload) → all authors

JSONPath Operators

OperatorDescription
$Root object
@Current object
. or []Child operator
..Recursive descent
*Wildcard
[,]Union operator
[start:end:step]Array slice
?()Filter expression

Debug Log

Press the button at the top left of a component to output debug logs.

debuglog

Debug logs show tp/tv/ap/av/cp/cv properties and variables in order.

Action program processing order:

  1. Retrieve component variables with Payload from queue
  2. Process PostMappings values from previous component
  3. Evaluate and assign PreMappings expressions
  4. Component performs its processing
  5. Create new component variables with new Payload
  6. Evaluate PostMappings expressions only
  7. Send new variables to next component's queue

Gravio Sensors

SensorCollection MethodFrequencyConfiguration
Climate SensorEvent drivenOnce per hour, or when temp ±0.5°C, humidity ±6%, pressure ±25PaNot configurable
Motion SensorMotion detectionOn motion, then 1-minute sleepNot configurable
Door SensorMagnetic sensorOn open/close, then 1-minute sleepNot configurable
Vibration SensorVibration detectionOn vibration, then 1-minute sleepNot configurable
Sound SensorMicrophoneOn sound (1 sec), then 1-minute sleepNot configurable
Light SensorLight detectionOn brightness change beyond thresholdThreshold configurable
Acceleration Sensor3-axis accelerometerOn acceleration beyond thresholdThreshold configurable