AI Task
AI Task 集成允许您借助 AI 来配置 Home Assistant。
This ai task is a building block integration that cannot be added to Home Assistant directly, but is used and provided by other integrations. A building block integration differs from a typical integration that connects to a device or service. Instead, other integrations use this ai task building block to provide entities, actions, and other functionality that you can use in your automations or dashboards. If one of your integrations uses this building block, this page documents the functionality the ai task building block offers.
对于每个任务,您可以设置首选的 AI 任务实体。这允许您为不同目的使用不同的 AI 模型,例如生成文本、总结信息,甚至控制设备。当动作中省略实体 ID 时,将使用首选的 AI 任务实体。
AI 任务实体状态
AI 任务实体的状态是一个时间戳,显示该 AI 任务上次使用的日期和时间。
动作 ai_task.generate_data
使用 AI 生成数据。
响应变量是一个包含以下键的字典:
data:生成的文本或结构化数据(取决于是否指定了structure)。conversation_id:用于任务的对话 ID。
动作 ai_task.generate_image
使用 AI 生成图像。
响应变量是一个包含以下键的字典:
media_source_id:生成图像的 媒体源 内容 ID。url:生成图像的 URL,不包含主机部分。URL 仅在一小时内有效。revised_prompt:某些模型会改写指令以添加更多细节或上下文。这是图像模型实际使用的提示词。model:用于图像生成的图像模型。mime_type:图像的 MIME 类型。width:图像宽度。height:图像高度。conversation_id:用于任务的对话 ID。
图像也将保存在第一个媒体目录中,并可通过媒体源集成浏览。
文件命名约定:
- 格式:
{date}_{time}_{sanitized_task_name}.{ext} - 示例:
2025-01-19_123456_home-security-camera.png
示例
计算摄像头上的物品的模板实体
其他想法:检测可用停车位数量、计算房间人数或检测门是否打开。

