Configuration
string
required
Jinja2 template that returns the function result
Examples
Get Current Weather
This simple example demonstrates template syntax:This is a simplified example from the OpenAI documentation.
Get Entity Attributes
Access state and attributes of one or multiple entities.Template Features
Access Entity States
Access Entity States
Filter and Select
Filter and Select
Date and Time
Date and Time
Math and Logic
Math and Logic
Use Cases
Entity Queries
Retrieve current states and attributes of entities
Calculations
Perform math operations on sensor values
Formatting
Format data for natural language responses
Filtering
Filter entities by state, area, or attributes
Best Practices
1
Keep templates simple
Use template functions for simple data retrieval. For complex logic, consider composite functions.
2
Handle missing values
Always use default values and safe filters:
3
Format for readability
Return human-readable text that the AI can use in responses:
Next Steps
Script Functions
Execute service sequences
Composite Functions
Combine templates with other functions
Template Documentation
Home Assistant templating guide