一键导入
ha-automation
Automation YAML patterns, triggers, conditions, actions, and best practices for Home Assistant.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Automation YAML patterns, triggers, conditions, actions, and best practices for Home Assistant.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Select and coordinate multi-agent teams (topology kits, role-based squads, lifecycle, worktree isolation). Use this skill whenever launching parallel agents, designing a review board, running a debug council, scheduling an orchestrator-workers team, configuring agent tool restrictions, or deciding between solo and team execution. Triggers on: "launch a team", "parallel agents", "review board", "debug council", "architect-implementer-reviewer", "swarm", "multi-agent", "subagents for X", "team topology", "agent lifecycle".
Select and wire an agentic design pattern (reflection, prompt chaining, routing, parallelization, orchestrator-workers, evaluator-optimizer, ReAct, blackboard) into the 5-layer Claude Code stack. Use this skill whenever deciding how to structure a multi-step task, whether to spawn subagents, how to run parallel review, or when to use which pattern. Triggers on: "which pattern", "orchestrate", "parallel review", "self-review", "chain of thought", "eval-optimizer loop", "blackboard", "ReAct", "how to decompose this task".
Auto mode permission handling — classifier-based approvals, PermissionDenied hook, defer permissionDecision, and autonomy profiles for hands-off Claude Code usage
Configure Claude Code's autonomous operating mode — profile selection (conservative, balanced, aggressive, unattended-review), permission blocks, and the three gate agents (planner, verifier, reviewer). Use this skill whenever enabling autonomous mode, switching profiles, tightening permissions for production branches, or setting up unattended execution. Triggers on: "autonomy", "unattended mode", "auto-approve", "permission mode", "autonomy profile", "gates", "/cc-autonomy", "planner verifier reviewer", "let claude run on its own".
Manage Claude Code's context window — token arithmetic, /compact strategy, anchor preservation, progressive loading, session analytics. Use this skill whenever a session gets long, context approaches limits, after /compact, when deciding what to load into CLAUDE.md vs leave in references, or when analyzing session cost/token usage. Triggers on: "context full", "compact", "too many tokens", "budget", "session analytics", "save tokens", "context window", "/compact strategy".
Evidence-driven deep analysis for hard coding problems — architecture decisions, root-cause investigation, high-stakes refactor planning, performance bottleneck isolation. Use this skill whenever the user asks for "the best approach", a "deep analysis", "root cause", "principal engineer review", or runs /cc-intel. Also triggers on hard debugging questions, major architectural choices, tricky performance problems, or any task where a hypothesis tree and evidence table matter more than a fast answer.
| name | ha-automation |
| description | Automation YAML patterns, triggers, conditions, actions, and best practices for Home Assistant. |
Automation YAML patterns, triggers, conditions, actions, and best practices for Home Assistant.
Activate this skill when:
# Complete automation template
alias: "Descriptive Name"
id: unique_automation_id # Optional but recommended
description: "What this automation does and why"
mode: single # single, restart, queued, parallel
# Variables available throughout
variables:
room: "living_room"
default_brightness: 80
trigger:
- platform: state
entity_id: binary_sensor.motion
to: "on"
id: motion_detected # For use in choose
condition:
- condition: sun
after: sunset
action:
- service: light.turn_on
target:
entity_id: "light.{{ room }}"
data:
brightness_pct: "{{ default_brightness }}"
trigger:
- platform: state
entity_id: binary_sensor.door
from: "off"
to: "on"
for:
seconds: 30
attribute: any # Optional: trigger on attribute change
trigger:
- platform: time
at: "06:30:00"
# Multiple times
- platform: time
at:
- "07:00:00"
- "12:00:00"
- "18:00:00"
# Input datetime
- platform: time
at: input_datetime.wake_up_time
trigger:
- platform: time_pattern
hours: "/2" # Every 2 hours
minutes: "30"
- platform: time_pattern
minutes: "/5" # Every 5 minutes
trigger:
- platform: sun
event: sunset
offset: "-01:00:00" # 1 hour before sunset
trigger:
- platform: numeric_state
entity_id: sensor.temperature
above: 75
below: 85
for:
minutes: 5
trigger:
- platform: template
value_template: >
{{ states('sensor.power') | float > 1000 and
is_state('input_boolean.high_power_alert', 'on') }}
for:
minutes: 5
trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "TURN_OFF_LIGHTS"
trigger:
- platform: device
type: turned_on
device_id: abc123def456
entity_id: switch.smart_plug
domain: switch
trigger:
- platform: webhook
webhook_id: my_custom_webhook
allowed_methods:
- POST
local_only: true
trigger:
- platform: mqtt
topic: "home/doorbell/status"
payload: "pressed"
condition:
- condition: state
entity_id: input_boolean.guest_mode
state: "off"
# Multiple states (OR)
- condition: state
entity_id: alarm_control_panel.home
state:
- "armed_home"
- "armed_away"
condition:
- condition: numeric_state
entity_id: sensor.battery
above: 20
condition:
- condition: time
after: "22:00:00"
before: "06:00:00"
weekday:
- mon
- tue
- wed
- thu
- fri
condition:
- condition: sun
after: sunset
before: sunrise
after_offset: "-00:30:00"
condition:
- condition: zone
entity_id: device_tracker.phone
zone: zone.home
condition:
- condition: template
value_template: >
{{ now().month in [6, 7, 8] }} # Summer months
condition:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.vacation
state: "off"
- condition: or
conditions:
- condition: state
entity_id: person.john
state: "home"
- condition: state
entity_id: person.jane
state: "home"
action:
- service: light.turn_on
target:
entity_id: light.kitchen
data:
brightness_pct: 100
transition: 2
action:
- service: light.turn_on
target:
entity_id: >
{{ expand('group.all_lights')
| selectattr('state', 'eq', 'on')
| map(attribute='entity_id')
| list }}
action:
- delay:
seconds: 30
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.door
to: "off"
timeout:
minutes: 5
continue_on_timeout: true
- wait_template: "{{ is_state('lock.front', 'locked') }}"
timeout: "00:01:00"
action:
- choose:
- conditions:
- condition: state
entity_id: sun.sun
state: "below_horizon"
sequence:
- service: light.turn_on
target:
entity_id: light.porch
data:
brightness_pct: 100
- conditions:
- condition: numeric_state
entity_id: sensor.illuminance
below: 100
sequence:
- service: light.turn_on
target:
entity_id: light.porch
data:
brightness_pct: 50
default:
- service: light.turn_off
target:
entity_id: light.porch
action:
- if:
- condition: state
entity_id: input_boolean.notify
state: "on"
then:
- service: notify.mobile_app
data:
message: "Alert!"
else:
- service: persistent_notification.create
data:
message: "Alert logged"
action:
# Repeat count
- repeat:
count: 3
sequence:
- service: light.toggle
target:
entity_id: light.alert
- delay:
milliseconds: 500
# While loop
- repeat:
while:
- condition: state
entity_id: binary_sensor.motion
state: "on"
sequence:
- delay:
seconds: 10
# For each
- repeat:
for_each:
- light.bedroom
- light.office
- light.kitchen
sequence:
- service: light.turn_off
target:
entity_id: "{{ repeat.item }}"
- delay:
seconds: 1
action:
- parallel:
- service: light.turn_on
target:
entity_id: light.living_room
- service: media_player.play_media
target:
entity_id: media_player.speaker
data:
media_content_id: "welcome_home.mp3"
media_content_type: "music"
action:
- service: weather.get_forecasts
target:
entity_id: weather.home
data:
type: daily
response_variable: forecast
- service: notify.mobile_app
data:
message: >
Tomorrow's forecast: {{ forecast['weather.home'].forecast[0].condition }}
# Current time
"{{ now().strftime('%H:%M') }}"
# Entity state
"{{ states('sensor.temperature') }}"
# State with default
"{{ states('sensor.battery') | float(100) }}"
# Attribute
"{{ state_attr('climate.thermostat', 'current_temperature') }}"
# Time since last change
"{{ (now() - states.sensor.motion.last_changed).seconds }}"
# Entity count
"{{ states.light | selectattr('state', 'eq', 'on') | list | count }}"
# Area entities
"{{ area_entities('Living Room') }}"
# Device entities
"{{ device_entities('device_id') }}"
single: Default, ignores new triggers while runningrestart: Stops current run, starts newqueued: Queues new triggersparallel: Runs multiple instancesaction:
- service: system_log.write
data:
message: "Automation triggered: {{ trigger.entity_id }}"
level: info