How to Automate a Smart Bulb with a Motion Sensor in Home Assistant

Hallway that has a motion sensor that automates turning on a light.
Hallway that has a motion sensor that automates turning on a light.

In This Article

Want your lights to turn on automatically when you walk into a room? In this guide, we’ll walk through how to use a motion sensor and a smart bulb in Home Assistant to create a responsive, hands-free lighting setup, complete with easy-to-use YAML code at the bottom of this article so you can copy and customize.

Jump To

Smart lighting is one of the most satisfying upgrades you can make to your home. With the right automation, your lights can turn on exactly when you need them and turn off when you leave. No more fumbling for switches or wasting energy when accidentally leaving lights on. In this guide, I’ll show you how to connect a motion sensor and a smart bulb in Home Assistant so that walking into a room automatically triggers the light. We’ll keep things simple but also explain each step, so even if you’re new to Home Assistant, you’ll understand how it works.

Step 1: Choose Your Devices

Before we create the automation, you’ll need two compatible devices:

For the best reliability, I recommend Zigbee or Z-Wave motion sensors paired with bulbs connected directly to your hub. Wi-Fi devices work too, but they may have slightly more delay.

Step 2: Connect Devices to Home Assistant

Open Home Assistant and make sure both the motion sensor and the smart bulb appear in Settings → Devices & Services. If either device is missing, follow the manufacturer’s pairing instructions to add it.
Once paired, test them individually:

  • Wave your hand in front of the motion sensor and confirm it shows as “Detected” or “On” in Home Assistant.
  • Turn your smart bulb on and off from the dashboard to make sure it responds.

Step 3: Plan Your Automation

Our automation will work like this:

  1. When the motion sensor detects movement, the light turns on.
  2. If no motion is detected for a set time (like 2-5 minutes depending on the room), the light turns off automatically.

This setup is ideal for spaces like hallways, closets, garages, or bathrooms where you don’t want lights on all the time. Rooms like a living room where you will be sitting down, will become frustrating because the motion sensor won’t see you sitting down for long periods of time. In that case, I’d recommend using a presence sensor.

Step 4: Create the Automation in YAML

You can make this automation in the visual editor, but YAML gives you more control and is easier to share. Here’s a simple example:

alias: Motion Sensor Light Automation
description: Turn on light when motion is detected, turn off after 2 minutes of no motion.
trigger:
  - platform: state
    entity_id: binary_sensor.hallway_motion
    to: "on"
condition: []
action:
  - service: light.turn_on
    target:
      entity_id: light.hallway_bulb
  - wait_for_trigger:
      - platform: state
        entity_id: binary_sensor.hallway_motion
        to: "off"
        for:
          minutes: 2
  - service: light.turn_off
    target:
      entity_id: light.hallway_bulb
mode: restart

Be sure to replace any entity ids with your own entity ids.

How It Works

  • Trigger: The automation starts when the motion sensor turns “on.”
  • Action Step 1: The light is turned on immediately.
  • Wait for Trigger: Home Assistant waits until the motion sensor is “off” for 2 minutes (in this example).
  • Action Step 2: Once no motion is detected for that time, the light turns off.
  • Mode Restart: This ensures that if motion happens again while the timer is running, the timer resets instead of turning the light off prematurely.

Step 5: Save and Test

After saving the automation, walk into the room to trigger it. Then leave and wait the set amount of time to see if the light turns off automatically. If there’s a delay, check the motion sensor’s responsiveness and battery level.

Conclusion

Automating a smart bulb with a motion sensor is one of the simplest ways to make your home feel truly “smart.” It’s energy efficient, convenient, and once you’ve got the basics down, you can add extra features like dimming at night, only triggering during certain hours, or using multiple sensors.

With Home Assistant’s flexibility, this basic automation can become part of a much larger smart home ecosystem, all starting from a single motion sensor and light.

FAQs: Motion Sensor Light Automation in Home Assistant

Can I use more than one motion sensor for a single light?

Yes. You can add multiple motion sensors to the automation’s trigger list in YAML or the visual editor. This is useful for larger spaces where a single sensor may not detect motion from every angle.

How do I make the light turn on only at night?

You can add a condition to check for the sun’s position or use time-based conditions. For example, you could set the automation to run only after sunset or between certain hours.

Will this work with multiple smart bulbs or switches?

Yes. Instead of one entity_id for the light, you can use a light group or add multiple entity IDs to the target section so they all turn on and off together.

What if the motion sensor keeps the light on when I don’t want it to?

You can adjust the wait_for_trigger time or the motion sensor’s built-in “clear” time. Shortening these times will make the light turn off faster after motion stops.

Can I make the light dim instead of turning off completely?

Yes. Instead of using light.turn_off in the final action, you can use light.turn_on with a lower brightness level. This works well for night lighting so the room isn’t completely dark.

Share the Post:

Disclaimer: Some of the links in this post are affiliate links, including Amazon. If you click through and make a purchase, we may earn a small commission at no extra cost to you. This helps support the site and allows us to continue providing helpful content. We only recommend products we personally use or trust.

Jump To

Related Posts

a smart humidifier in a bedroom of a smart home. this is the thumbnail for an article called best smart humidifiers for 2026
Product Reviews

The Best Smart Humidifier for 2026 for Healthier Indoor Air

Dry indoor air is one of those problems you do not always notice right away. But over time, it can affect your sleep, dry out your skin, irritate sinuses, and make your home feel uncomfortable, especially during colder months.

A good humidifier can make a noticeable difference. The right model helps balance indoor humidity, improve comfort, and create a healthier living environment without constant maintenance or noise.

In this guide, we break down the best humidifiers for 2026 based on real-world use, room size, ease of cleaning, noise level, and smart features. Whether you need a humidifier for a bedroom, a large living space, or an entire home, these are the models worth considering this year.

Read More »
amazon alexa turning off air conditioner because a window is open
Automation Ideas

An HVAC Automation That Saves Money When Windows Are Open

You’ll learn how a simple automation can prevent air conditioning from running while windows are open.It explains the real-world problem, the logic behind the solution, and how the automation works. The focus is on improving comfort, reducing energy waste, and keeping the system easy to manage.

Read More »
smart home modern living room
Smart Home Basics

How Many Smart Homes Are There

Smart homes are becoming more common every year as technology becomes easier and more affordable. Millions of households now use devices like smart speakers, thermostats, lights, and security systems. This rapid growth is changing the way people live, making homes more convenient, energy-efficient, and secure. As adoption continues to rise, smart technology is shaping the future of modern living in exciting ways.

Read More »