Templating
Templates are short snippets of code you can use wherever Home Assistant needs to figure something out for you. Instead of typing a fixed message or value, you write a small instruction that reads your data and produces the right result.
For example, instead of a notification that always says “Someone is home”, a template can say “Frenck is home” or “Nobody is home, they’re at the gym” depending on what’s actually happening.
Quick example
action: notify.mobile_app
data:
message: >
{% if is_state('device_tracker.frenck', 'home') %}
Frenck is home.
{% else %}
Frenck is at {{ states('device_tracker.frenck') }}.
{% endif %}
Frenck is at gym.
The text between {%, %} and {{, }} is the template. When the action runs, Home Assistant replaces it with the right message.
Learning guide
Start here if you are new to templating in Home Assistant. The pages below walk you through the concepts step by step.
Tutorials
Two step-by-step walkthroughs that show templating in practice.
Reference
Home Assistant provides hundreds of template functions, filters, and tests for working with your data. Each one has its own page with explanations and examples.
- Template functions reference. Browse all functions, filters, and tests by category.