node-red-contrib-home-assistant-websocketnode-red-contrib-home-assistant-websocket
Guides
Nodes
FAQ
Cookbook
Scrubber
Discussions
Discord
Github
Guides
Nodes
FAQ
Cookbook
Scrubber
Discussions
Discord
Github
  • Guides

    • Getting Started
    • First Automation
    • Action Node Tips and Tricks
    • Conditionals
    • Mustache Templates
    • JSONata

      • JSONata
      • JSONata primer
    • Diagnostics Information
  • Custom Integration

    • Getting Started
    • Exposed Nodes
  • Contribute to

    • Development
    • Documentation

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.

Help us improve this page!
Last Updated:
Contributors: Jason
Prev
Conditionals