ha-automations について
ha-automations は、Home Assistant のオートメーション、スクリプト、シーン作成を支援するスキルです。トリガーや条件、アクション、ブループリント、実行モードを扱います。
主な機能
- 01トリガー・条件・アクションの作成
- 02スクリプトとシーンの設定
- 03オートメーションのブループリント利用
- 04オートメーションの実行モード選択
活用シーン
- 01デバイスの状態変化を操作の契機にする
- 02時刻や条件に応じたデバイス制御
- 03遅延・待機・分岐アクションの記述
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ laurigates/ claude-plugins --skill ha-automationsインストール後、Claude Code で/ha-automationsを入力して読み込まれたか確認します。
同梱ファイルREFERENCE.md
詳細
Home Assistant のオートメーション
このスキルを使う場面
| 次のような場合にこのスキルを使います… | 次のような場合は ha-configuration を使います… |
|---|---|
| オートメーションルールを作成する | configuration.yaml を編集する |
| トリガー/条件/アクションを記述する | インテグレーションを設定する |
| スクリプトやシーンを扱う | シークレットを管理する |
| ブループリントを使う | パッケージを整理する |
| デバイストリガーを設定する | 一般的な YAML 設定を行う |
オートメーションの構造
automation:
- id: "unique_automation_id"
alias: "Descriptive Name"
description: "What this automation does"
mode: single # single, restart, queued, parallel
trigger:
- platform: state
entity_id: binary_sensor.motion
to: "on"
condition:
- condition: time
after: "08:00:00"
before: "22:00:00"
action:
- service: light.turn_on
target:
entity_id: light.living_room
トリガーの種類
状態トリガー
trigger:
# Basic state change
- platform: state
entity_id: binary_sensor.door
to: "on"
from: "off"
# With duration
- platform: state
entity_id: binary_sensor.motion
to: "off"
for:
minutes: 5
# Attribute change
- platform: state
entity_id: climate.thermostat
attribute: current_temperature
時刻トリガー
trigger:
# Specific time
- platform: time
at: "07:00:00"
# Input datetime
- platform: time
at: input_datetime.alarm_time
# Time pattern (every hour)
- platform: time_pattern
hours: "*"
minutes: 0
seconds: 0
# Every 15 minutes
- platform: time_pattern
minutes: "/15"
その他のトリガーの種類(数値状態、太陽、デバイス、イベント、Webhook、テンプレート、ゾーン)については、REFERENCE.md を参照してください。
条件の種類
状態条件
condition:
# Single entity
- condition: state
entity_id: binary_sensor.door
state: "off"
# Multiple states allowed
- condition: state
entity_id: alarm_control_panel.home
state:
- armed_home
- armed_away
# Check for duration
- condition: state
entity_id: binary_sensor.motion
state: "off"
for:
minutes: 10
時刻条件
condition:
# Time range
- condition: time
after: "08:00:00"
before: "22:00:00"
# Weekdays only
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
# Combined
- condition: time
after: "09:00:00"
before: "17:00:00"
weekday:
- mon
- tue
- wed
- thu
- fri
その他の条件の種類(数値状態、太陽、テンプレート、ゾーン、論理、簡略記法)については、REFERENCE.md を参照してください。
アクションの種類
サービス呼び出し
action:
# Basic service call
- service: light.turn_on
target:
entity_id: light.living_room
data:
brightness_pct: 80
color_temp: 350
# Multiple targets
- service: light.turn_off
target:
entity_id:
- light.bedroom
- light.bathroom
area_id: upstairs
遅延と待機
action:
- service: light.turn_on
target:
entity_id: light.living_room
# Fixed delay
- delay:
seconds: 30
# Wait for trigger
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.motion
to: "off"
timeout:
minutes: 5
continue_on_timeout: true
# Wait for template
- wait_template: "{{ is_state('light.bedroom', 'off') }}"
timeout: "00:05:00"
If/Then/Else(モダン)
action:
- if:
- condition: state
entity_id: binary_sensor.motion
state: "on"
then:
- service: light.turn_on
target:
entity_id: light.hallway
else:
- service: light.turn_off
target:
entity_id: light.hallway
高度なアクションパターン(choose、repeat、変数、並列実行)、スクリプト、シーン、一般的なオートメーションパターンについては、REFERENCE.md を参照してください。
オートメーションモード
| モード | 動作 |
|---|---|
single | 実行中は新しいトリガーを無視する |
restart | 現在の実行を停止して、新たに開始する |
queued | 最大 max 回の実行をキューに追加する |
parallel | 最大 max 回を並列実行する |
automation:
- alias: "Motion Light"
mode: restart
max: 10 # For queued/parallel
max_exceeded: silent # silent, warning, error
エージェント向けの最適化
| 用途 | コマンド |
|---|---|
| オートメーションを検索する | grep -r "alias:" config/automations.yaml |
| トリガーを検索する | grep -r "platform: state" config/ --include="*.yaml" |
| スクリプトを一覧表示する | grep -r "^ [a-z_]*:" config/scripts.yaml |
| シーンを検索する | grep -r "^ - name:" config/scenes.yaml |
| オートメーション ID を確認する | grep -r "^ - id:" config/automations.yaml |
コメント
Markdown 対応