---
name: home-assistant-automation
description: "Author Home Assistant YAML automations and scripts. Triggers, conditions, scenes, dashboards. Builds HA automations correctly the first time — proper trigger syntax, useful conditions, multi-action scripts, and Lovelace dashboard cards. Knows the breaking changes per HA release."
license: MIT
---

# Home Assistant Automation

Authoring Home Assistant automations by hand means juggling trigger platforms, template syntax, and YAML indentation that the UI editor hides from you. This skill writes correct `automation`, `script`, `scene`, and Lovelace dashboard YAML the first time, and it tracks the breaking changes that move config keys around between HA releases. It is for people who edit `automations.yaml` and `configuration.yaml` directly, or who paste YAML into the automation editor's "Edit in YAML" mode.

## When to use it

- You want a multi-step automation (trigger on motion, check sun elevation, fade lights, send a notification) and don't want to wire it together in the visual editor.
- A `template` sensor or `trigger` keeps throwing "expected dict for dictionary value" and you can't see why.
- You upgraded HA and an automation broke because a key was renamed (e.g. `service:` becoming `action:`, or the `platform:` trigger key migrating to `trigger:`).
- You're building a Lovelace view and need `entities`, `grid`, `mushroom`, or `custom:` cards laid out correctly.

## How it works

It produces the real HA schema: triggers using platforms like `state`, `numeric_state`, `time`, `time_pattern`, `template`, `mqtt`, `zone`, and `event`. Conditions use `and`/`or`/`not`, `state`, `numeric_state`, and `template`. Actions call services with `action:` (or `service:` on older cores), support `choose`, `repeat`, `wait_for_trigger`, `parallel`, and `variables`. It writes Jinja2 templates with `trigger.to_state.state`, `states('sensor.x')`, `is_state()`, and `now()`, and knows where double braces vs `{% %}` blocks belong. Dashboard output targets Lovelace card schemas including conditional and `vertical-stack` cards.

## Usage

```
curl -fsSL --create-dirs -o ~/.claude/skills/home-assistant-automation/SKILL.md https://claudeskil.com/skills/home-assistant-automation/SKILL.md

> "When the front door opens after sunset, turn on the hallway light
   to 60% for 5 minutes, but only if nobody is already home."
```

```yaml
- alias: Hallway light on door open after dark
  trigger:
    - trigger: state
      entity_id: binary_sensor.front_door
      to: "on"
  condition:
    - condition: state
      entity_id: group.family
      state: "not_home"
    - condition: sun
      after: sunset
  action:
    - action: light.turn_on
      target: { entity_id: light.hallway }
      data: { brightness_pct: 60 }
    - delay: "00:05:00"
    - action: light.turn_off
      target: { entity_id: light.hallway }
mode: restart
```

## Tips & gotchas

- Use `mode: restart` (not the default `single`) for delay-based automations, or a re-trigger leaves the light stuck on.
- `for:` on a state trigger resets if any other tracked attribute changes; pin it with the `state:` and an explicit `attribute:` if needed.
- Quote `"on"`/`"off"`/`"yes"` — YAML otherwise parses them as booleans and the state comparison silently fails.
- `numeric_state` ignores non-numeric states like `unavailable`; guard with a template if a sensor drops out.

## FAQ

**Will edits here clash with the UI automation editor?** No — the YAML it writes round-trips through the editor as long as you keep the `id:` field.

**Does it handle Blueprints?** Yes, it can author `blueprint:` input schemas and reference `!input` placeholders.

**Which HA version does it assume?** It targets current cores using `trigger:`/`action:` keys but will emit the legacy `platform:`/`service:` form on request for older installs.
