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:
- A motion sensor – Zigbee, Z-Wave, or Wi-Fi based sensors all work as long as Home Assistant can detect them. (I used the Aqara Zigbee Motion Sensor P1)
- A smart bulb – Any dimmable or color-capable bulb that integrates with Home Assistant will work. (I used the Sengled Zigbee Smart Light Bulbs)
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:
- When the motion sensor detects movement, the light turns on.
- 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.




