重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
ha-configuration by laurigates/claude-plugins
npx skills add https://github.com/laurigates/claude-plugins --skill ha-configuration| 使用此技能当... | 改用 ha-automations 当... |
|---|---|
| 编辑 configuration.yaml | 创建自动化规则 |
| 设置集成 | 编写自动化触发器/动作 |
| 管理 secrets.yaml | 调试自动化逻辑 |
| 使用包进行组织 | 使用自动化蓝图 |
| 排查配置错误 | 设置设备触发器 |
| 文件 | 用途 |
|---|---|
configuration.yaml | 主要配置入口点 |
secrets.yaml | 敏感值(密码、API 密钥、令牌) |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
automations.yaml | 自动化规则(通常由 UI 管理) |
scripts.yaml | 可重用的脚本序列 |
scenes.yaml | 场景定义 |
customize.yaml | 实体自定义 |
packages/*.yaml | 模块化配置包 |
homeassistant:
name: Home
unit_system: metric
time_zone: Europe/Helsinki
currency: EUR
country: FI
# 外部文件
customize: !include customize.yaml
packages: !include_dir_named packages/
# 核心集成
default_config:
# 文本转语音
tts:
- platform: google_translate
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
secrets.yaml:
# API 密钥
openweathermap_api_key: "abc123def456"
spotify_client_id: "your_client_id"
spotify_client_secret: "your_client_secret"
# 数据库
recorder_db_url: "postgresql://user:pass@localhost/hass"
# MQTT
mqtt_username: "homeassistant"
mqtt_password: "secure_password"
# 网络
latitude: 60.1699
longitude: 24.9384
在 configuration.yaml 中引用:
weather:
- platform: openweathermap
api_key: !secret openweathermap_api_key
recorder:
db_url: !secret recorder_db_url
| 指令 | 描述 | 示例 |
|---|---|---|
!include | 包含单个文件 | !include automations.yaml |
!include_dir_list | 将文件包含为列表项 | !include_dir_list sensors/ |
!include_dir_named | 将文件包含为命名映射 | !include_dir_named packages/ |
!include_dir_merge_list | 将文件合并到单个列表中 | !include_dir_merge_list automations/ |
!include_dir_merge_named | 将文件合并到单个映射中 | !include_dir_merge_named integrations/ |
!secret | 引用 secrets.yaml 中的值 | !secret api_key |
!env_var | 环境变量 | !env_var DB_PASSWORD |
包允许按领域进行模块化配置:
packages/climate.yaml:
climate_package:
sensor:
- platform: template
sensors:
average_indoor_temp:
friendly_name: "平均室内温度"
unit_of_measurement: "°C"
value_template: >-
{{ (states('sensor.living_room_temp') | float +
states('sensor.bedroom_temp') | float) / 2 | round(1) }}
automation:
- alias: "气候 - 空调自动关闭"
trigger:
- platform: numeric_state
entity_id: sensor.average_indoor_temp
below: 22
action:
- service: climate.turn_off
target:
entity_id: climate.living_room_ac
script:
climate_cool_down:
alias: "房屋降温"
sequence:
- service: climate.set_temperature
target:
entity_id: climate.living_room_ac
data:
temperature: 20
hvac_mode: cool
packages/presence.yaml:
presence_package:
input_boolean:
guest_mode:
name: "访客模式"
icon: mdi:account-multiple
binary_sensor:
- platform: template
sensors:
anyone_home:
friendly_name: "家中有人"
device_class: presence
value_template: >-
{{ is_state('person.user1', 'home') or
is_state('person.user2', 'home') or
is_state('input_boolean.guest_mode', 'on') }}
mqtt:
broker: !secret mqtt_broker
port: 1883
username: !secret mqtt_username
password: !secret mqtt_password
discovery: true
discovery_prefix: homeassistant
sensor:
- name: "室外温度"
state_topic: "sensors/outdoor/temperature"
unit_of_measurement: "°C"
device_class: temperature
value_template: "{{ value_json.temperature }}"
sensor:
- platform: rest
name: "GitHub 星标数"
resource: https://api.github.com/repos/home-assistant/core
value_template: "{{ value_json.stargazers_count }}"
scan_interval: 3600
headers:
Authorization: !secret github_token
template:
- sensor:
- name: "太阳高度角"
unit_of_measurement: "°"
state: "{{ state_attr('sun.sun', 'elevation') | round(1) }}"
- name: "日照时长"
unit_of_measurement: "小时"
state: >-
{% set sunrise = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
{% set sunset = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
{{ ((sunset - sunrise) / 3600) | round(1) }}
- binary_sensor:
- name: "工作日"
state: "{{ now().weekday() < 5 }}"
input_boolean:
vacation_mode:
name: "度假模式"
icon: mdi:airplane
input_number:
target_temperature:
name: "目标温度"
min: 16
max: 28
step: 0.5
unit_of_measurement: "°C"
icon: mdi:thermometer
input_select:
house_mode:
name: "房屋模式"
options:
- 在家
- 外出
- 睡眠
- 访客
icon: mdi:home
input_text:
notification_message:
name: "自定义通知"
max: 255
input_datetime:
alarm_time:
name: "闹钟时间"
has_date: false
has_time: true
# Docker/容器
docker exec homeassistant hass --script check_config
# Home Assistant OS
ha core check
# Supervised
hassio homeassistant check
# Python venv
hass --script check_config -c /path/to/config
| 错误 | 原因 | 修复方法 |
|---|---|---|
found undefined alias | 缺少 !secret 值 | 添加到 secrets.yaml |
could not determine a constructor | 无效的 YAML 语法 | 检查缩进 |
duplicate key | 重复定义相同的键 | 移除重复项 |
Platform not found | 缺少集成 | 通过 UI/HACS 安装 |
recorder:
db_url: !secret recorder_db_url
purge_keep_days: 10
commit_interval: 1
exclude:
domains:
- automation
- updater
entity_globs:
- sensor.weather_*
entities:
- sun.sun
- sensor.date
include:
domains:
- sensor
- binary_sensor
- switch
logger:
default: warning
logs:
homeassistant.core: info
homeassistant.components.mqtt: debug
custom_components.my_integration: debug
# 减少噪音
homeassistant.components.websocket_api: error
# configuration.yaml
lovelace:
mode: yaml
resources:
- url: /hacsfiles/button-card/button-card.js
type: module
dashboards:
lovelace-home:
mode: yaml
filename: dashboards/home.yaml
title: 主页
icon: mdi:home
show_in_sidebar: true
| 模式 | 示例 |
|---|---|
| 多行字符串 | value: >- 或 `value: |
| 列表项 | - item |
| 内联列表 | [item1, item2] |
| 注释 | # comment |
| 锚点 | &anchor_name |
| 引用 | *anchor_name |
| 合并 | <<: *anchor_name |
| 函数 | 示例 |
|---|---|
| 状态值 | states('sensor.temp') |
| 状态属性 | state_attr('sun.sun', 'elevation') |
| 转换为浮点数 | `states('sensor.temp') |
| 四舍五入 | `value |
| 默认值 | `states('sensor.x') |
| 时间戳 | as_timestamp(now()) |
| 时间差 | now() - timedelta(hours=1) |
| 上下文 | 命令 |
|---|---|
| 验证配置 | `docker exec homeassistant hass --script check_config 2>&1 |
| 查找实体使用情况 | grep -r "entity_id:" config/ --include="*.yaml" |
| 查找密钥引用 | grep -r "!secret" config/ --include="*.yaml" |
| 列出包 | ls -la config/packages/ |
| 检查 YAML 语法 | python3 -c "import yaml; yaml.safe_load(open('file.yaml'))" |
每周安装次数
56
仓库
GitHub 星标数
23
首次出现
2026年2月9日
安全审计
安装于
opencode56
gemini-cli56
github-copilot56
codex56
amp56
kimi-cli56
| Use this skill when... | Use ha-automations instead when... |
|---|---|
| Editing configuration.yaml | Creating automation rules |
| Setting up integrations | Writing automation triggers/actions |
| Managing secrets.yaml | Debugging automation logic |
| Organizing with packages | Working with automation blueprints |
| Troubleshooting config errors | Setting up device triggers |
| File | Purpose |
|---|---|
configuration.yaml | Main configuration entry point |
secrets.yaml | Sensitive values (passwords, API keys, tokens) |
automations.yaml | Automation rules (usually UI-managed) |
scripts.yaml | Reusable script sequences |
scenes.yaml | Scene definitions |
customize.yaml | Entity customizations |
packages/*.yaml | Modular configuration packages |
homeassistant:
name: Home
unit_system: metric
time_zone: Europe/Helsinki
currency: EUR
country: FI
# External files
customize: !include customize.yaml
packages: !include_dir_named packages/
# Core integrations
default_config:
# Text-to-speech
tts:
- platform: google_translate
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
secrets.yaml:
# API keys
openweathermap_api_key: "abc123def456"
spotify_client_id: "your_client_id"
spotify_client_secret: "your_client_secret"
# Database
recorder_db_url: "postgresql://user:pass@localhost/hass"
# MQTT
mqtt_username: "homeassistant"
mqtt_password: "secure_password"
# Network
latitude: 60.1699
longitude: 24.9384
Reference in configuration.yaml:
weather:
- platform: openweathermap
api_key: !secret openweathermap_api_key
recorder:
db_url: !secret recorder_db_url
| Directive | Description | Example |
|---|---|---|
!include | Include single file | !include automations.yaml |
!include_dir_list | Include files as list items | !include_dir_list sensors/ |
!include_dir_named | Include files as named mappings | !include_dir_named packages/ |
!include_dir_merge_list |
Packages allow modular configuration by domain:
packages/climate.yaml:
climate_package:
sensor:
- platform: template
sensors:
average_indoor_temp:
friendly_name: "Average Indoor Temperature"
unit_of_measurement: "°C"
value_template: >-
{{ (states('sensor.living_room_temp') | float +
states('sensor.bedroom_temp') | float) / 2 | round(1) }}
automation:
- alias: "Climate - AC Auto Off"
trigger:
- platform: numeric_state
entity_id: sensor.average_indoor_temp
below: 22
action:
- service: climate.turn_off
target:
entity_id: climate.living_room_ac
script:
climate_cool_down:
alias: "Cool Down House"
sequence:
- service: climate.set_temperature
target:
entity_id: climate.living_room_ac
data:
temperature: 20
hvac_mode: cool
packages/presence.yaml:
presence_package:
input_boolean:
guest_mode:
name: "Guest Mode"
icon: mdi:account-multiple
binary_sensor:
- platform: template
sensors:
anyone_home:
friendly_name: "Anyone Home"
device_class: presence
value_template: >-
{{ is_state('person.user1', 'home') or
is_state('person.user2', 'home') or
is_state('input_boolean.guest_mode', 'on') }}
mqtt:
broker: !secret mqtt_broker
port: 1883
username: !secret mqtt_username
password: !secret mqtt_password
discovery: true
discovery_prefix: homeassistant
sensor:
- name: "Outdoor Temperature"
state_topic: "sensors/outdoor/temperature"
unit_of_measurement: "°C"
device_class: temperature
value_template: "{{ value_json.temperature }}"
sensor:
- platform: rest
name: "GitHub Stars"
resource: https://api.github.com/repos/home-assistant/core
value_template: "{{ value_json.stargazers_count }}"
scan_interval: 3600
headers:
Authorization: !secret github_token
template:
- sensor:
- name: "Sun Elevation"
unit_of_measurement: "°"
state: "{{ state_attr('sun.sun', 'elevation') | round(1) }}"
- name: "Daylight Hours"
unit_of_measurement: "hours"
state: >-
{% set sunrise = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
{% set sunset = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
{{ ((sunset - sunrise) / 3600) | round(1) }}
- binary_sensor:
- name: "Workday"
state: "{{ now().weekday() < 5 }}"
input_boolean:
vacation_mode:
name: "Vacation Mode"
icon: mdi:airplane
input_number:
target_temperature:
name: "Target Temperature"
min: 16
max: 28
step: 0.5
unit_of_measurement: "°C"
icon: mdi:thermometer
input_select:
house_mode:
name: "House Mode"
options:
- Home
- Away
- Sleep
- Guest
icon: mdi:home
input_text:
notification_message:
name: "Custom Notification"
max: 255
input_datetime:
alarm_time:
name: "Alarm Time"
has_date: false
has_time: true
# Docker/Container
docker exec homeassistant hass --script check_config
# Home Assistant OS
ha core check
# Supervised
hassio homeassistant check
# Python venv
hass --script check_config -c /path/to/config
| Error | Cause | Fix |
|---|---|---|
found undefined alias | Missing !secret value | Add to secrets.yaml |
could not determine a constructor | Invalid YAML syntax | Check indentation |
duplicate key | Same key defined twice | Remove duplicate |
Platform not found | Missing integration | Install via UI/HACS |
recorder:
db_url: !secret recorder_db_url
purge_keep_days: 10
commit_interval: 1
exclude:
domains:
- automation
- updater
entity_globs:
- sensor.weather_*
entities:
- sun.sun
- sensor.date
include:
domains:
- sensor
- binary_sensor
- switch
logger:
default: warning
logs:
homeassistant.core: info
homeassistant.components.mqtt: debug
custom_components.my_integration: debug
# Reduce noise
homeassistant.components.websocket_api: error
# configuration.yaml
lovelace:
mode: yaml
resources:
- url: /hacsfiles/button-card/button-card.js
type: module
dashboards:
lovelace-home:
mode: yaml
filename: dashboards/home.yaml
title: Home
icon: mdi:home
show_in_sidebar: true
| Pattern | Example |
|---|---|
| Multi-line string | value: >- or `value: |
| List item | - item |
| Inline list | [item1, item2] |
| Comment | # comment |
| Anchor | &anchor_name |
| Reference | *anchor_name |
| Merge |
| Function | Example |
|---|---|
| State value | states('sensor.temp') |
| State attribute | state_attr('sun.sun', 'elevation') |
| Convert to float | `states('sensor.temp') |
| Round | `value |
| Default value | `states('sensor.x') |
| Timestamp | as_timestamp(now()) |
| Time delta | now() - timedelta(hours=1) |
| Context | Command |
|---|---|
| Validate config | `docker exec homeassistant hass --script check_config 2>&1 |
| Find entity usage | grep -r "entity_id:" config/ --include="*.yaml" |
| Find secret refs | grep -r "!secret" config/ --include="*.yaml" |
| List packages | ls -la config/packages/ |
| Check YAML syntax | python3 -c "import yaml; yaml.safe_load(open('file.yaml'))" |
Weekly Installs
56
Repository
GitHub Stars
23
First Seen
Feb 9, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode56
gemini-cli56
github-copilot56
codex56
amp56
kimi-cli56
GitHub Actions 官方文档查询助手 - 精准解答 CI/CD 工作流问题
49,000 周安装
| Merge files into single list |
!include_dir_merge_list automations/ |
!include_dir_merge_named | Merge files into single mapping | !include_dir_merge_named integrations/ |
!secret | Reference from secrets.yaml | !secret api_key |
!env_var | Environment variable | !env_var DB_PASSWORD |
<<: *anchor_name |