|
| 1 | +--- |
| 2 | +title: AI Task |
| 3 | +description: Instructions on how to setup AI task entities with Home Assistant. |
| 4 | +ha_category: |
| 5 | + - AI |
| 6 | +ha_release: '2025.7' |
| 7 | +ha_quality_scale: internal |
| 8 | +ha_domain: ai_task |
| 9 | +ha_codeowners: |
| 10 | + - '@home-assistant/core' |
| 11 | +ha_integration_type: entity |
| 12 | +--- |
| 13 | + |
| 14 | +The **AI Task** {% term integration %} allows you to use AI to help you configure Home Assistant. |
| 15 | + |
| 16 | +{% include integrations/building_block_integration.md %} |
| 17 | + |
| 18 | +For each task, you can set a preferred AI task entity. This allows you to use different AI models for different purposes, such as generating text, summarizing information, or even controlling devices. When the entity ID is omitted in the action, the preferred AI task entity will be used. |
| 19 | + |
| 20 | +## The state of an AI task entity |
| 21 | + |
| 22 | +The {% term state %} of an AI task {% term entity %} is a timestamp showing the date and time when the AI task was last used. |
| 23 | + |
| 24 | +## Action `ai_task.generate_text` |
| 25 | + |
| 26 | +Generates text using AI. |
| 27 | + |
| 28 | +| Data attribute | Optional | Description | |
| 29 | +| ---------------------- | -------- | --------------------------------------------------------------------------------------------------------------- | |
| 30 | +| `task_name` | no | String that identifies the type of text generation task (for example, "home summary", "alert notification"). | |
| 31 | +| `instructions` | no | String containing the specific instructions for the AI to follow when generating the text. | |
| 32 | +| `entity_id` | yes | String that points at an `entity_id` of an LLM task entity. If not specified, uses the default LLM task. | |
| 33 | + |
| 34 | +The response variable is a dictionary with the following keys: |
| 35 | + |
| 36 | +- `text`: The generated text. |
| 37 | +- `conversation_id`: The ID of the conversation used for the task. |
| 38 | + |
| 39 | +## Example |
| 40 | + |
| 41 | +{% raw %} |
| 42 | +```yaml |
| 43 | +# Example: Generate a notification when garage door is left open |
| 44 | +automation: |
| 45 | +- alias: "Garage door notification" |
| 46 | + triggers: |
| 47 | + - trigger: state |
| 48 | + entity_id: cover.garage_door |
| 49 | + to: 'on' |
| 50 | + for: |
| 51 | + minutes: 10 |
| 52 | + actions: |
| 53 | + - action: ai_task.generate_text |
| 54 | + data: |
| 55 | + task_name: "garage door left open comment" |
| 56 | + instructions: "Generate a funny notification that garage door was left open" |
| 57 | + response_variable: generated_text |
| 58 | + - action: notify.mobile_app |
| 59 | + data: |
| 60 | + message: "{{ generated_text.result }}" |
| 61 | +``` |
| 62 | +{% endraw %} |
0 commit comments