社区自动化蓝图一键套用
什么是 Blueprint
Blueprint 是 Home Assistant 社区里的自动化模板共享机制。它让开发者可以把一个完整的自动化(触发器、条件、动作)打包成一份 Blueprint,其他用户导入后只需要填几个参数(选设备、起名字)就能用——不需要懂 YAML,不需要一步步搭触发器。
Blueprint 把自动化分享体验拉到了 App Store 一样的级别。
去哪里找 Blueprint
Home Assistant 官方 Blueprint 市场
Settings → Automations & scenes → Blueprints → Browse the Home Assistant Blueprint Exchange
这是官方的蓝图交换市场,按类别浏览。每半年 Home Assistant 会精选一批加 Spotlight 标签。
Home Assistant Community Forum
community.home-assistant.io 的 Share your Projects 板块,很多作者发布 Blueprint。
GitHub 搜索
site:github.com "homeassistant" "blueprint" 可以找到大量社区蓝图仓库。
导入 Blueprint
拿到 Blueprint 链接(一个 https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=xxx 链接)后:
- 确保 Home Assistant 实例能访问外网
- 浏览器打开那个链接 → 自动跳转到 Home Assistant 的 Blueprint 导入页面
- 确认 Blueprint 内容 → 点击 Create
- 跳到 Blueprint 配置页面,填写需要的参数:
- 选择要用哪些设备(实体)
- 设置自定义名称
- 调整可选的阈值
- 点击 Save → Blueprint 变成你自己的自动化了
典型 Blueprint 示例
示例一:日落自动开走廊灯
blueprint:
name: Sunset Corridor Light
description: 日落时走廊灯渐亮到 50%,23:00 后关灯
inputs:
target_light:
name: 走廊灯
selector:
entity:
domain: light
brightness:
name: 亮度
default: 50
selector:
number:
min: 10
max: 100
turn_off_time:
name: 关灯时间
default: "23:00"
selector:
time: {}
triggers:
- trigger: sun
event: sunset
offset: "-00:15:00"
actions:
- service: light.turn_on
target:
entity_id: !input target_light
data:
brightness_pct: !input brightness
- wait_for:
trigger:
- trigger: time
at: !input turn_off_time
- service: light.turn_off
target:
entity_id: !input target_light
用户导入时只需要选灯、填亮度百分比、填关灯时间——就能用了。
示例二:离家模式
Home Assistant 官方自带一个 "Away Mode" Blueprint,功能非常全:
- 检测到你离开家(GPS 或手机 Wi-Fi)
- 关闭所有灯和媒体
- 锁门、关车库门
- 调低恒温器
- 启动报警(如果布防)
- 发通知确认
导入后选几个"哪些灯"、"哪些门"、"谁离开时触发"就能跑。
自己写 Blueprint
写 Blueprint 和写普通 YAML 自动化几乎一样,只是把需要用户填的地方换成 !input:
blueprint:
name: 我的自动化
description: 简短描述
inputs:
entity_foo:
name: 选择一个实体
selector:
entity:
custom_param:
name: 参数
default: "默认值"
selector:
text:
# 下面是普通的 automation 配置,用 !input 引用 inputs 里定义的变量
triggers:
- trigger: state
entity_id: !input entity_foo
to: "on"
actions:
- service: notify.mobile_app_me
data:
message: "{{ !input custom_param }}"
写好后保存到 config/blueprints/automation/你的名字/ 目录下,刷新后 HACS/Blueprint 页面就能看到。
Blueprint vs. 直接 YAML
| 对比项 | Blueprint | 直接 YAML 自动化 |
|---|---|---|
| 用途 | 分享给别人用 | 自己机器上跑 |
| 参数化 | ✅ 有 inputs | ❌ 写死 |
| 可读性 | 好(结构化) | 看 YAML 功底 |
| 可修改 | 导入后变成普通自动化 | 随时改 |
| 社区价值 | 高(复用) | 低(一次性) |
常见问题
Blueprint 导入后报 "Invalid config"
Blueprint 本身可能有问题。先用社区市场里 stars 高的。
Blueprint 里的 !input 变量不会用
在 Blueprint 的 YAML 里,!input xxx 会被替换成用户在配置界面里填的值。普通 YAML 里写 !input 会报错。
如何更新已导入的 Blueprint
Home Assistant 目前没有自动更新机制。新版本出来后可以重新导入,再把配置参数复制过来。旧版本的自动化实例不受影响。