Beginner: Your First Automation and Scenes in Home Assistant
Create your first motion-activated light automation and learn how to save and restore device states with Scenes. Includes UI steps and YAML examples.
Search results
Automations make things happen automatically; Scenes save and recall a set of device states. Here’s a simple, reliable first setup.
What You’ll Need
- A motion sensor that is already connected to Home Assistant. If you need help choosing one, see our guide to hardware for Home Assistant .
- A smart light (like a Philips Hue bulb) that is also connected.
- About 10 minutes.
Example 1: Motion turns on a light (UI steps)
- Settings → Automations & Scenes → Create Automation → “Start with an empty automation”.
- Trigger: Device → your motion sensor → “Detects motion”.
- Condition (optional): Time → After sunset.
- Action: Device → your light → Turn on.
- Save and test.
YAML equivalent
automation:
- alias: Hall light on motion at night
trigger:
- platform: state
entity_id: binary_sensor.hall_motion
to: "on"
condition:
- condition: sun
after: sunset
action:
- service: light.turn_on
target:
entity_id: light.hall
Example 2: Auto-off after inactivity
Add a second automation to turn the light off if there’s no motion for 5 minutes.
automation:
- alias: Hall light off after 5 min no motion
trigger:
- platform: state
entity_id: binary_sensor.hall_motion
to: "off"
for: "00:05:00"
action:
- service: light.turn_off
target:
entity_id: light.hall
Scenes: Save and restore device states
- Create a Scene (Settings → Automations & Scenes → Scenes → Add) with your preferred device states.
- Call the scene from an automation or a button.
Example: A “Movie” scene and a button to activate it.
scene:
- name: Movie
entities:
light.living_room:
state: "on"
brightness_pct: 20
light.tv_backlight:
state: "on"
brightness_pct: 5
script:
movie_mode:
alias: Movie Mode
sequence:
- service: scene.turn_on
target:
entity_id: scene.movie
Next steps
- Add occupancy conditions (combine motion + contact sensors).
- Use the Sun, Weather, or Time helpers for smarter lighting.
- Expose scenes to voice assistants for quick control. For more on this, see our guide to creating schedules for voice assistants .
References
Last modified April 3, 2026: Add landing page for Smart Locks ad group (f280efd)