Presence-Aware Room Lighting with Manual Control
The lighting follows presence, and the wall switch keeps doing its job. You set up the sensors, two automations and an easy manual mode.
- Level
- Intermediate
- Active time
- 2–3 hours
- Home Assistant required
- Yes
What you will build
You’re sitting on the sofa, reading, and the lamp goes off. According to the sensor, you’re apparently no longer at home. This small argument with the lighting is exactly what you want to settle.
Pick Sonoff SNZB-06P for presence and Shelly 1PM Gen4 for the lamp. Sonoff SNZB-04P adds information on whether the door is open. Home Assistant runs the rules.
The SNZB-06P works with a 5.8 GHz microwave radar and can detect presence from small movements. Its placement and setup matter.
The door sensor only knows “open” or “closed”. It doesn’t know who comes in, who goes out and how many people remain inside. That’s why you won’t entrust it with the decision of when to turn off.
1. Add and check the sensors
Before the first setup, make a backup of Home Assistant.
Add the two Sonoff sensors in the Zigbee integration you use, one by one. Name them clearly, for example “Living room: presence” and “Living room: door”.
Before you fix them in place for good, you check the reported states. You open and close the door, walk into the room and walk out. The changes should show up in Home Assistant.
Align the door contact and the magnet according to the SNZB-04P instructions. First you check the spot, then you stick it. The reverse order usually ends with a search for a new adhesive pad.
2. Check the Shelly and the wall switch
After installation, you add the relay through the Shelly. You check whether you can turn the lamp on and off from Home Assistant and from the wall switch.
The switch input must control the relay locally. The Detached mode separates the input from the output and is not suitable for the independent manual control wanted here.
Choose the right mode for the installed switch or button. Also check the behaviour after a power cut and restoration.
3. Find the right spot for presence
Point the SNZB-06P at the place where you actually sit. You test with a book, a laptop and a TV, not just by waving in front of it. The lamp has to put up with you even when you’re not doing anything interesting.
Then you leave the room empty. Moving curtains, a fan or a pet can cause unwanted detection. The radar can also pass through some non-metal partitions.
Change the position and the settings available in your Zigbee integration. Don’t assume every integration shows the same controls. First fix the detection, then add the automation.
4. Make two clear automations
Start with two separate rules: one for turning on and one for turning off. That way it’s easier to understand which one fired and why.
When you turn on
- Trigger: the sensor switches to “presence detected”.
- Conditions: automatic mode is on and light is needed. For a first trial you can use “after sunset”; this won’t cover a dark room during the day.
- Action: you turn on the Shelly output the lamp is connected to.
If you use an illuminance reading, first check what the integration provides and when it updates it. Don’t set an arbitrary lux threshold on a sensor that only reports “light/dark”.
When you turn off
- Trigger: the sensor is continuously in “no presence” for the chosen time.
- Condition: automatic mode is on.
- Action: you turn off the same Shelly output.
Three minutes is a starting trial, not a universal setting. To that you add the time the sensor itself takes to report the release. With new presence, the wait has to start over.
Choose the specific state for no presence, not “anything other than occupied”. An unavailable sensor does not mean an empty room.
The door stays an add-on. If you like, opening it can turn on the lamp under the same conditions. But then it will also light up when you leave. Closing is not a command to turn off.
5. Leave the last word to the person
In Settings → Devices & services → Helpers you create a Toggle helper named “Automatic lighting: living room”. Add it as a condition in both rules from the previous step.
Put the switch on the shared dashboard. When you want manual mode, first turn it off, then use the wall switch. The automations will no longer change the lighting.
Pressing the wall switch itself does not turn off automatic mode in this project. Without this arrangement, the person and the automation would toss the lamp back and forth like a ball.
When automatic mode is turned back on, these simple rules wait for the next event from the sensor. They don’t immediately change the lamp’s current state.
6. Check with a normal day at home
- Walk in after dark and check the turn-on. Repeat during the day, when the light condition should stop it.
- You sit calmly for at least a few minutes. The lamp must not go off because of a lack of large movements.
- Leave, then come back before the wait ends. Check that the old wait doesn’t turn the lamp off.
- Stop automatic mode and use the wall switch. The rules must not override your choice.
- At a convenient time you stop Home Assistant and check the local wall switch. Then you restore the system and check the sensors.
A wait with for is not preserved when Home Assistant restarts or the automations are reloaded. After such a case you check the lamp; you don’t rely on the old countdown to finish turning it off.
If something fires unexpectedly, you open the automation’s trace and the sensor’s history. That way you tell a wrong detection from a wrong rule, instead of changing five settings at once.
Sources
Description based on the official documentation. The suggested rules are an example setup, not a report from a physical test of this kit with the Shelly 1PM Gen4. What actually works at Marto’s is described in “At home” at the beginning.
- SONOFF SNZB-06P: power, radar and placement
- Shelly 1PM Gen4: device and requirements
- Shelly: input modes and local control
- Home Assistant: Shelly integration
- Home Assistant: Toggle helper
- Home Assistant: conditions
- Home Assistant: triggers and waiting with for
- Blackshome: Sensor Light blueprint, used in our kitchen
At home
MartoSince March 2025
In the bathroom and the kitchen, our lighting follows presence and both automations are on. In the kitchen it's the Sonoff SNZB-06P through ZHA: automation.kitchen_occupancy_turns_lights_on uses the ready-made Sensor Light blueprint by Blackshome and turns the LED strip off 5 minutes after presence ends (created in June 2026). In the bathroom it's the Aqara Presence Sensor FP300: automation.motion_activated_bathroom_lights_2 turns the lamp on at 11 % brightness during the night period, 35 % after sunset and 60 % during the day, and turns it off with a 9-second fade as soon as the sensor reports "no presence". The bathroom has no switch for automatic mode, so we haven't tested the manual mode from step 5 there.
Need a hand?
We can set up and install everything in this project. In some regions we install it ourselves — ask us.
Contact us






