Blog

Home Assistant Motion Sensor Light Automation

8/12/2025 2 min read
Home Assistant Motion Sensor Light Automation

At first glance, one might think that setting up a Home Assistant motion sensor light automation is a piece of cake. Unfortunately, it's not that simple. Although there is now a pre-made automation called "Motion-activated Light", it does not display MQTT devices, for example, and also lacks extensive configuration options.
So how do you create your own motion sensor automation?


The Problem

A simple automation using a motion sensor as a trigger can be set up quickly.
For example:

WHEN the motion sensor detects movement,
THEN turn the light on for 3 minutes.

However, you'll quickly notice that the light turns off after these 3 minutes — regardless of whether movement was detected again in the meantime.
This is not what we want.

The goal is that the 3-minute countdown resets every time new movement is detected.


The Solution

To create a motion sensor automation that resets the countdown on every new movement, you can use the following automation:

alias: Motion Sensor Light Automation  # Name of the automation
description: ""  # Description (optional)
trigger:
  - platform: state
    entity_id:
      - binary_sensor.motion_sensor  # Motion sensor entity
    to: "on"  # Trigger when motion is detected
condition: []
action:
  - service: light.turn_on  # Action: turn light on
    data:
      transition: 3  # Transition time of 3 seconds
      brightness_pct: 100  # Brightness set to 100%
    target:
      entity_id: light.target_light  # The light to control
  - wait_for_trigger:  # Wait until specific conditions are met
      - platform: state
        entity_id:
          - binary_sensor.motion_sensor  # Same motion sensor
        to: "off"  # Wait until no motion is detected
        for:
          minutes: 1  # And this for at least 1 minute
  - service: light.turn_off  # Action: turn light off
    target:
      entity_id: light.target_light  # The light to control
mode: restart  # Mode: restart automation if triggered again

Explanation

With this automation, the light automatically turns on as soon as the motion sensor detects movement. The automation reacts to the state change of the motion sensor to "on" and turns on the desired light with a smooth transition time of 3 seconds to 100% brightness.

Then the automation waits for the motion sensor to detect no movement. This state must persist for at least one minute before the light is switched off.

The restart mode ensures that the automation restarts as soon as movement is detected again during the wait time. That way, the light stays on as long as there is movement in the room and only switches off when the room is actually vacated.


Note

You can also configure the automation entirely via the Home Assistant GUI. A corresponding example screenshot would be shown here.