Skip to main content
Functions are the core mechanism for extending your AI assistant’s capabilities. Each function defines what the AI can do and how it executes actions.

Function Structure

Every function consists of two parts:

Specification (spec)

The spec follows OpenAI’s function schema format:
  • name: Function identifier (used by AI to call the function)
  • description: Clear explanation of what the function does
  • parameters: JSON schema defining expected parameters
Write clear, detailed descriptions. The AI uses these to decide when and how to call functions.

Function Implementation

The function section defines how to execute the function:
  • type: Function type (see below)
  • Additional configuration specific to the function type

Function Types

Native

Built-in functions provided by the component

Template

Return dynamic values using Jinja2 templates

Script

Execute sequences of Home Assistant services

REST

Fetch data from external REST APIs

Scrape

Extract data from web pages

Composite

Chain multiple function types together

SQLite

Query Home Assistant’s database

Bash

Execute shell commands with security controls

Read File

Read file contents safely with path restrictions

Write File

Write content to files safely with path restrictions

Edit File

Safely edit files with find-and-replace operations

Reserved Parameters

Delay Parameter

Add a delay to execute functions in the background after a specified time:

Default Functions

Extended OpenAI Conversation includes this default function:
This function allows the AI to control any exposed Home Assistant entity.

Adding Custom Functions

Add functions through the Options configuration:
1

Open Options

Navigate to Settings > Voice Assistants > Edit Assistant > Options
2

Edit Functions

Scroll to the “Functions” field
3

Add YAML

Paste your function definition in YAML format
4

Save

Click “Submit” to apply changes

Best Practices

Write detailed descriptions that explain exactly what the function does and when to use it. The AI relies on these descriptions to choose the right function.✅ Good: “Get the current weather and forecast for a specific location using the weather entity”❌ Bad: “Get weather”
Define all required parameters with clear descriptions and appropriate types.
Test each function with various inputs before deploying to production. Check edge cases and error handling.
Choose the simplest function type that meets your needs. Don’t use composite functions when a template would suffice.

Next Steps

Native Functions

Built-in functions

Template Functions

Dynamic templates

Script Functions

Service sequences