Walk into a room and have the lights come on by themselves, then switch off once you leave, with no app and no voice command. That is the most satisfying automation in any smart home, and in Home Assistant it is built from three plain building blocks: a trigger, an optional condition, and an action. Once you see how those three pieces fit together, you can build it from scratch in a few minutes and tweak it forever.
Quick Answer
A motion-activated light in Home Assistant uses a trigger (the motion sensor detecting movement), an optional condition (the sun being below the horizon so it only runs after dark), and an action (turn the light on). A second action with a short timer, around five minutes, switches the light off automatically once the room clears. That trigger, condition, action structure is the whole pattern.
How a Home Assistant automation thinks
Every automation follows the same logic. A trigger wakes it up. Home Assistant then checks any conditions you have set, and only if they all pass does it run the actions. Get that order clear in your head and the rest is just filling in the blanks:
- Trigger is the event that starts everything, here, motion being detected.
- Condition is an optional gate, a yes or no test that must pass, like "is it dark enough to bother?"
- Action is what actually happens, turning the light on, and later, off.
You build all three in the automation editor, no code required, though Home Assistant shows you the underlying YAML if you want to peek.
Step 1: Create the automation and set the trigger
In Home Assistant, go to Settings, then Automations and Scenes, and create a new automation, starting empty. For the trigger, choose a state trigger on your motion sensor and set it to fire when the sensor changes to the "on" (motion detected) state. The instant someone walks in, this trigger fires and the automation begins evaluating.
Step 2: Add the sun condition (optional but worth it)
You probably do not want the lights snapping on at midday. Add a condition so the automation only continues after dark. The cleanest way is a sun condition: set it to require the sun to be below the horizon. Home Assistant exposes the sun's position through the sun.sun entity, and for fine control you can use its elevation, a value between roughly 0 and minus 6 degrees covers dusk if you want the lights coming on as the light fades rather than only after full dark. With this condition in place, daytime motion is ignored and the automation does nothing, exactly as it should.
Step 3: Set the action to turn the light on
Add an action that calls the light turn-on service and points it at the light or group you want. You can stop here for the simplest version, but most people want one more thing: the light turning itself off.
Step 4: Make the light turn off on its own
There are two common ways to handle the off side.
The simpler approach is a second action right after the first: turn the light on, then wait a fixed delay (say five minutes), then turn it off. This works well in low-traffic rooms. Its weakness is that if you are still in the room and moving, the delay does not reset, so the light can switch off while you are sitting there.
The more robust approach uses motion stopping as the trigger for switching off. You set the automation so that when the motion sensor reports "no motion" continuously for a set period, two minutes is a common choice, the off action runs. Because the timer effectively restarts every time fresh motion is seen, the light stays on as long as the room is genuinely occupied and only switches off once it has truly been still. For most rooms this is the better behaviour.
Step 5: Save, test and tune
Save the automation and test it directly. Trigger it from the automation page to confirm the light responds, then walk into the room after dark and watch it fire for real. From there it is all tuning: lengthen the off delay in a room where you sit still, like a study or lounge, and shorten it in a hallway where you only pass through. If the lights nag by switching off too soon, that delay is your dial.
A clean result depends on good hardware: a responsive PIR motion sensor and smart bulbs or switches that Home Assistant talks to reliably. You can see compatible kit in the smart home range at Evetech, and the sensors, hubs and plugs that round out a setup turn up in the accessories best sellers if you are filling gaps in an existing system.
Frequently Asked Questions
What are the three parts of a Home Assistant automation?
Trigger, condition and action. The trigger starts the automation, the condition is an optional gate that must pass, and the action is what runs. For motion lights, that is motion detected, sun below horizon, and turn the light on.
How do I stop the lights coming on during the day?
Add a sun condition requiring the sun to be below the horizon, or use the sun.sun elevation attribute (around 0 to minus 6 degrees for dusk). With that condition, daytime motion is ignored and the lights only respond after dark.
How do I make the light turn off automatically?
Either add a fixed delay after turning on, then a turn-off action, or trigger the off action when the motion sensor reports no motion for a set time like two minutes. The second method is better because the light stays on while the room is genuinely occupied.
Why does my light switch off while I'm still in the room?
A fixed delay does not know you are still there. Switch to an off trigger based on the motion sensor reporting no motion for a period, so the effective timer resets with each new detection and the light only goes off once movement truly stops.
Do I need to write code for this?
No. Home Assistant's automation editor lets you build the trigger, condition and action visually. It generates the underlying YAML for you, which you can view or edit later if you want finer control.
Ready to make your lights respond to you instead of a switch? Browse the smart home range at Evetech for motion sensors and smart lighting that pair cleanly with Home Assistant.