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:
- Trigger — the event that starts the automation
- Condition — an optional check that must be true
- 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 Type | Use Case |
|---|---|
state | Entity changes state (e.g., motion detected) |
time | Specific time of day |
sun | Sunrise or sunset |
zone | Device enters/leaves a zone |
mqtt | MQTT 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_booleanhelpers to add manual override switches
Happy automating!