mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-30 04:36:51 +00:00
Update AI Task example to be IoT related (#39900)
Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
parent
a368621566
commit
acb1f3f984
@ -40,51 +40,83 @@ The response variable is a dictionary with the following keys:
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
### Template entity counting items on a camera
|
||||||
|
|
||||||
|
{% raw %}
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
template:
|
||||||
|
- triggers:
|
||||||
|
- trigger: homeassistant
|
||||||
|
event: start
|
||||||
|
- trigger: time_pattern
|
||||||
|
minutes: "/5" # update every 5 minutes
|
||||||
|
actions:
|
||||||
|
- action: ai_task.generate_data
|
||||||
|
data:
|
||||||
|
task_name: "{{ this.entity_id }}"
|
||||||
|
instructions: >-
|
||||||
|
This is the inside of my goose coop. How many birds (chickens, geese, and
|
||||||
|
ducks) are inside the coop?
|
||||||
|
structure:
|
||||||
|
birds:
|
||||||
|
selector:
|
||||||
|
number:
|
||||||
|
attachments:
|
||||||
|
media_content_id: media-source://camera/camera.chicken_coop
|
||||||
|
media_content_type: image/jpeg
|
||||||
|
response_variable: result
|
||||||
|
sensor:
|
||||||
|
- name: "Chickens"
|
||||||
|
state: "{{ result.data.birds }}"
|
||||||
|
state_class: total
|
||||||
|
```
|
||||||
|
|
||||||
|
{% endraw %}
|
||||||
|
|
||||||
|
Alternative ideas: detect number of parking spots available, count people in a room, or detect if a door is open.
|
||||||
|
|
||||||
### Structured output example
|
### Structured output example
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example: Generate structured user profile data
|
# Example: Generate weather and indoor comfort report
|
||||||
script:
|
script:
|
||||||
- alias: "Create fake user profile"
|
- alias: "Weather and comfort report"
|
||||||
sequence:
|
sequence:
|
||||||
- action: ai_task.generate_data
|
- action: ai_task.generate_data
|
||||||
data:
|
data:
|
||||||
task_name: "user profile generation"
|
task_name: "weather comfort report"
|
||||||
instructions: "Generate a profile for a new user"
|
instructions: |
|
||||||
|
Based on the current conditions:
|
||||||
|
- Outdoor temperature: {{ states('sensor.outdoor_temperature') }}°C
|
||||||
|
- Weather condition: {{ states('weather.home') }}
|
||||||
|
- Indoor temperature: {{ states('sensor.living_room_temperature') }}°C
|
||||||
|
- Indoor humidity: {{ states('sensor.living_room_humidity') }}%
|
||||||
|
|
||||||
|
Generate a funny weather description and assess indoor comfort level.
|
||||||
structure:
|
structure:
|
||||||
name:
|
weather_description:
|
||||||
description: "First and last name of the user"
|
description: "A humorous description of the current weather outside"
|
||||||
required: true
|
required: true
|
||||||
selector:
|
selector:
|
||||||
text:
|
text:
|
||||||
age:
|
indoor_comfort:
|
||||||
description: "Age of the user"
|
description: "Assessment of how comfortable it is inside compared to outside"
|
||||||
required: true
|
required: true
|
||||||
selector:
|
selector:
|
||||||
number:
|
text:
|
||||||
min: 0
|
response_variable: comfort_report
|
||||||
max: 120
|
|
||||||
interests:
|
|
||||||
description: "List of user interests"
|
|
||||||
required: true
|
|
||||||
selector:
|
|
||||||
select:
|
|
||||||
options:
|
|
||||||
- "Technology"
|
|
||||||
- "Sports"
|
|
||||||
- "Music"
|
|
||||||
- "Travel"
|
|
||||||
multiple: true
|
|
||||||
attachments:
|
|
||||||
- media_content_id: "media-source://user_profile_image.jpg"
|
|
||||||
media_content_type: "image/jpeg"
|
|
||||||
response_variable: user_profile
|
|
||||||
- action: notify.persistent_notification
|
- action: notify.persistent_notification
|
||||||
data:
|
data:
|
||||||
title: "New User Profile"
|
title: "🏠 Home climate report"
|
||||||
message: "Name: {{ user_profile.data.name }}, Age: {{ user_profile.data.age }}, Interests: {{ user_profile.data.interests | join(', ') }}"
|
message: |
|
||||||
|
🌤️ **Weather outside:**
|
||||||
|
{{ comfort_report.data.weather_description }}
|
||||||
|
|
||||||
|
🛋️ **Indoor comfort:**
|
||||||
|
{{ comfort_report.data.indoor_comfort }}
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user