home-assistantautomationsbeginner

Getting Started with Home Assistant Automations

Home Assistant automations are the heart of any smart home. They let your home react to events automatically — turning on lights when you walk in, locking doors at bedtime, or adjusting the thermostat based on weather.

How Automations Work

Every automation has three parts:

  1. Trigger — the event that starts the automation
  2. Condition — an optional check that must be true
  3. Action — what happens when triggered

Here’s an interactive visualization of a simple hallway light automation. Click Run to see it in action:

Automation Flow

triggerMotion Detected

binary_sensor.hallway_motion

conditionAfter Sunset

sun.sun state: below_horizon

actionTurn On Lights

light.hallway → on, brightness: 80%

Writing Your First Automation

Here’s the YAML for the automation shown above:

automation:
  - alias: "Hallway motion light"
    trigger:
      - platform: state
        entity_id: binary_sensor.hallway_motion
        to: "on"
    condition:
      - condition: sun
        after: sunset
    action:
      - service: light.turn_on
        target:
          entity_id: light.hallway
        data:
          brightness_pct: 80

Key Concepts

Triggers

Triggers listen for events in your system. Common trigger types:

Trigger TypeUse Case
stateEntity changes state (e.g., motion detected)
timeSpecific time of day
sunSunrise or sunset
zoneDevice enters/leaves a zone
mqttMQTT message received

Conditions

Conditions gate whether the automation runs. You can combine them with and, or, and not:

condition:
  - condition: and
    conditions:
      - condition: sun
        after: sunset
      - condition: state
        entity_id: input_boolean.guest_mode
        state: "off"

Actions

Actions are what your automation actually does. You can chain multiple actions:

action:
  - service: light.turn_on
    target:
      entity_id: light.hallway
    data:
      brightness_pct: 80
      transition: 2
  - delay: "00:05:00"
  - service: light.turn_off
    target:
      entity_id: light.hallway

Next Steps

  • Browse the Home Assistant Automation docs for the full reference
  • Try creating a “Welcome Home” automation that triggers when your phone connects to Wi-Fi
  • Experiment with input_boolean helpers to add manual override switches

Happy automating!