Skip to main content
Script functions execute sequences of Home Assistant services, similar to Home Assistant scripts. They’re perfect for multi-step actions or calling services with specific data.

Configuration

array
required
List of service calls to execute in order

Basic Examples

Add Item to Shopping Cart

Shopping List

Send Notification

Notification

Advanced Examples

Get Calendar Events

Use response_variable to pass service results back to the AI:
Calendar Events
Set response_variable: _function_result to return the service response to the AI.

Play YouTube on TV

Chain multiple service calls with delays:
YouTube

Play Netflix on TV

Netflix

Get Weather Forecasts

Script Features

Target entities, devices, or areas:
Add delays between service calls:
Capture service responses:
The response is passed back to the AI as the function result.
Use Jinja2 templates in service data:

Use Cases

Multi-step Actions

Execute sequences of services in order

Data Retrieval

Call services and return responses to AI

Media Control

Control media players with complex payloads

Notifications

Send messages through various notification services

Best Practices

1

Use response_variable for data

When you need the AI to process service results, always set response_variable: _function_result
2

Add delays when needed

Some devices need time to process commands. Add appropriate delays between service calls.
3

Target correctly

Use the most appropriate targeting method:
  • entity_id for specific entities
  • device_id for all entities of a device
  • area_id for all entities in an area
4

Keep sequences focused

Each function should accomplish one logical task. For complex workflows, use composite functions.

Next Steps

REST Functions

Fetch external data

Composite Functions

Chain multiple functions

Script Integration

Home Assistant scripts