Motion Sensor Light Automation

automation lights motion-sensor

This automation turns on lights when motion is detected and turns them off after 5 minutes of no motion.

Basic Motion Light

Here’s a simple automation that controls a light based on motion:

alias: "Motion Light - Hallway"
description: "Turn on hallway light when motion detected"
trigger:
  - platform: state
    entity_id: binary_sensor.hallway_motion
    to: "on"
condition:
  - condition: sun
    after: sunset
    before: sunrise
action:
  - service: light.turn_on
    target:
      entity_id: light.hallway
    data:
      brightness_pct: 100
  - wait_for_trigger:
      - platform: state
        entity_id: binary_sensor.hallway_motion
        to: "off"
        for:
          minutes: 5
  - service: light.turn_off
    target:
      entity_id: light.hallway
mode: restart

Key Components

Trigger

The automation triggers when the motion sensor changes to “on” state.

Condition

Only runs between sunset and sunrise (during dark hours).

Action

  1. Turns on the light at 100% brightness
  2. Waits for 5 minutes of no motion
  3. Turns off the light

Mode

restart mode ensures that if motion is detected again while waiting, the timer resets.