Mustache Templates
When using templates, the top level refers to a property of the message object. For example, msg.payload
would be accessed as {{payload}}
.
You can also access flow
, global
, and states
contexts with the following syntax:
flow
context:{{flow.foobar}}
global
context:{{global.something}}
states
context: Use{{entity.domain.entity_id}}
to get the state, or drill further down with{{entity.light.kitchen.attributes.friendly_name}}
.
Note:
{{entity.light.kitchen}}
and{{entity.light.kitchen.state}}
are equivalent.
By default, Mustache will replace certain characters with their HTML escape codes. To prevent this, use triple braces: {{{payload}}}
.
Warning
Mustache templates are ideal for handling strings. However, if you need to insert a JSON object, consider using a JSONata expression or handling it with a function node and passing it as an input.