AWS IoT Events reference for inputs and variables in expressions
- Inputs
-
$input.
input-name
.path-to-data
input-name
is an input that you create using the CreateInput action.For example, if you have an input named
TemperatureInput
for which you definedinputDefinition.attributes.jsonPath
entries, the values might appear in the following available fields.{ "temperature": 78.5, "date": "2018-10-03T16:09:09Z" }
To reference the value of the
temperature
field, use the following command.$input.TemperatureInput.temperature
For fields whose values are arrays, you can reference members of the array using
[
. For example, given the following values:n
]{ "temperatures": [ 78.4, 77.9, 78.8 ], "date": "2018-10-03T16:09:09Z" }
The value
78.8
can be referenced with the following command.$input.TemperatureInput.temperatures[2]
- Variables
-
$variable.
variable-name
The
is a variable that you defined using the CreateDetectorModel action.variable-name
For example, if you have a variable named
TechnicianID
that you defined usingdetectorDefinition.states.onInputEvents.actions.setVariable.variableName
, you can reference the (string) value most recently given to the variable with the following command.$variable.TechnicianID
You can set the values of variables only using the
setVariable
action. You can't assign values for variables in an expression. A variable can't be unset. For example, you can't assign it the valuenull
.
Note
In references that use identifiers that don't follow the (regular expression) pattern
[a-zA-Z][a-zA-Z0-9_]*
, you must enclose those identifiers in backticks
(`
). For example, a reference to an input named MyInput
with a
field named _value
must specify this field as
$input.MyInput.`_value`
.
When you use references in expressions, check the following:
-
When you use a reference as an operand with one or more operators, make sure that all data types that you reference are compatible.
For example, in the following expression, integer
2
is an operand of both the==
and&&
operators. To ensure that the operands are compatible,$variable.testVariable + 1
and$variable.testVariable
must reference an integer or decimal.In addition, integer
1
is an operand of the+
operator. Therefore,$variable.testVariable
must reference an integer or decimal.‘$variable.testVariable + 1 == 2 && $variable.testVariable’
-
When you use a reference as an argument passed to a function, make sure that the function supports the data types that you reference.
For example, the following
timeout("
function requires a string with double quotes as the argument. If you use a reference for thetime-name
")timer-name
value, you must reference a string with double quotes.timeout("
timer-name
")Note
For the
convert(
function, if you use a reference for thetype
,expression
)type
value, the evaluated result of your reference must beString
,Decimal
, orBoolean
.
AWS IoT Events expressions support integer, decimal, string, and Boolean data types. The following table provides a list of incompatible pairs of types.
Incompatible pairs of types |
---|
Integer, string |
Integer, Boolean |
Decimal, string |
Decimal, Boolean |
String, Boolean |