Sets a property based on the provided template.

Inputs

message struct
A message object containing information to populate the template.

Note: When not using Mustache, select Plain text in Format to save ressources.

Outputs

Setting Output as to Plain text always outputs a String. Setting it to Parsed JSON parses the template and converts it according to the JSON rules (i. e. 20 is parsed to an Integer, 20.1 to a Float, "My text" to a String, [0, 2, 3] to an Array and so on).

message struct
a message with a property set by populating the configured template with properties from the incoming message.

Details

By default this uses the mustache format, but this can be switched off if required.

For example, when a template of:

Hello {{name}}. Today is {{date}}

receives a message containing:

{
  name: "Fred",
  date: "Monday"
  payload: ...
}

The resulting property will be:

Hello Fred. Today is Monday

It is possible to use a property from the flow context or global context. Just use {{flow.name}} or {{global.name}}.

You can also access environment variables using {{env.name}}

Furthermore you can access device variables using {{variable.peerId_channel_variableName}} (e. g. {{variable.5_1_STATE}}).

Arrays

Array elements can be accessed using the array index. E. g. for a message of {"payload":["first","second","third"]} {{payload.1}} would generate an output of second.

Note: By default, mustache will escape any HTML entities in the values it substitutes. To prevent this, use {{{triple}}} braces.

Note 2: If one of the message's the top level properties contains a reserved keyword (e. g. variable), the propertie's name is postfixed with _ (e. g. variable_).