Configuring Hybrid mmWave and PIR Presence Lighting in Home Assistant
Configure responsive, reliable staircase and hallway lighting in Home Assistant using a battery mmWave radar, a PIR motion sensor, delivery retries, and a safety timeout to eliminate false triggers and stuck lights.

Tested on: Tested on Home Assistant with Zigbee2MQTT, utilizing a Sonoff ZBDongle-E coordinator, a Tuya TS0505B smart bulb, a Sonoff ZBMini-L2 relay, a Tuya TS0601 mmWave radar sensor, and a Sonoff SNZB-03P PIR motion sensor. The safety cutoff was tested by running it once by hand while the sensor was stuck; the sensitivity change (8 to 7) is recent and not yet evaluated.
Before you start
Staircases and connecting hallways present a classic home automation challenge: standard PIR sensors trigger quickly on entry but lose track of people walking slowly or standing still, while mmWave radar detects stationary presence but can suffer from wake delays, high battery drain, or false triggers. Relying on a single sensor often results in lights shutting off mid-walk or remaining stuck on.
In this guide, you will configure a hybrid Zigbee presence lighting system in Home Assistant using a battery mmWave radar sensor at the top of the stairs, a fast-reacting PIR motion sensor at the bottom, an installed smart bulb, and a no-neutral relay module. You will set up hardware timeouts in Zigbee2MQTT, write robust automation logic with delivery retries, and add a safety timeout failsafe.
What you need
- Home Assistant instance with Zigbee2MQTT integration
- Zigbee 3.0 Coordinator (e.g., Sonoff ZBDongle-E)
- Zigbee smart bulb (e.g., Tuya TS0505B white/color bulb)
- Zigbee no-neutral relay switch (e.g., Sonoff ZBMini-L2)
- Battery-powered Zigbee mmWave radar sensor with illuminance (e.g., Tuya TS0601 / _TZE284_gnpflcoq)
- Battery-powered Zigbee PIR motion sensor (e.g., Sonoff SNZB-03P)
- Rechargeable NiMH or alkaline AAA batteries and coin cell batteries for sensors
Step 1 · Verify Prerequisites and Standardize Entity Names
Before writing automation rules, confirm that your Zigbee coordinator, smart bulb, and relay module are joined to Zigbee2MQTT and integrated into Home Assistant.
Assign standardized, descriptive entity IDs to your devices. In this setup, we control a smart staircase bulb and a hallway light relay using inputs from a top mmWave sensor (with presence and illuminance entities) and a bottom PIR motion sensor.
light:
- light.stairs_light # Tuya TS0505B Zigbee bulb
switch:
- switch.hallway_light # Sonoff ZBMini-L2 relay
binary_sensor:
- binary_sensor.stairs_top_presence # Tuya TS0601 mmWave radar
- binary_sensor.stairs_bottom_occupancy # Sonoff SNZB-03P PIR motion
sensor:
- sensor.stairs_top_illuminance # Lux sensor on the mmWave unitStep 2 · Pair and Configure the Top mmWave Radar Sensor
Pair the Tuya TS0601 mmWave radar sensor using fresh batteries. Note that pairing with weak or depleted batteries can cause the device to join the network without reporting states, flashing its red LED intermittently.
If the sensor joins but reports empty or null data, wake the sensor by moving in front of it and trigger a device configure request via MQTT. Once active, configure fading_time and sensitivity. Setting fading_time to 30 seconds (it was 15) fixed the light switching off while someone stood still on the stairs. For sensitivity (0-10) I first used 8 after my tests. Later the sensor stayed on "present" for hours with nobody there, so I lowered it to 7; it is too early to say whether that fixes it, which is why the safety cutoff in step 6 matters.
// Reconfigure request (send while waking the sensor up):
Topic: zigbee2mqtt/bridge/request/device/configure
Payload: {"id": "Sensor Stairs Top"}
// Set operational parameters (send while waking the sensor up):
Topic: zigbee2mqtt/Sensor Stairs Top/set
Payload: {
"fading_time": 30,
"sensitivity": 7
}Step 3 · Pair and Configure the Bottom PIR Motion Sensor
Pair the Sonoff SNZB-03P PIR motion sensor at the bottom landing. Because stairs are transit zones, a fast clear time ensures lights turn off promptly when leaving the staircase from the bottom.
Configure motion_timeout to 20 seconds (down from the default 60 seconds). Note that unlike mmWave devices, this PIR sensor does not support occupancy_sensitivity or occupancy_timeout. Additionally, the illumination state on this sensor only updates upon wake-up, which can lead to stale readings; do not rely on its illumination reading for instant switching decisions.
// Set PIR motion timeout via MQTT:
Topic: zigbee2mqtt/Sensor PIR Stairs Bottom/set
Payload: {
"motion_timeout": 20
}Step 4 · Configure Hardware Power Defaults on Bulb and Relay
Set default power-on behaviors for both lighting actuators so they recover gracefully after power interruptions.
On the smart bulb (Tuya TS0505B), enable do_not_disturb: true so the light remains off if grid power cuts and restores in the middle of the night. On the no-neutral relay (Sonoff ZBMini-L2), configure power_on_behavior: off. Remember that the bulb acts as a Zigbee Router, while the no-neutral relay functions as an EndDevice that routes through nearby mains nodes.
// Configure smart bulb defaults:
Topic: zigbee2mqtt/Stairs Light/set
Payload: {
"do_not_disturb": true
}
// Configure no-neutral relay defaults:
Topic: zigbee2mqtt/Hallway Light/set
Payload: {
"power_on_behavior": "off"
}Step 5 · Implement the Core Hybrid Presence Automation
Create the primary automation in Home Assistant using mode: restart. This automation coordinates both sensors and actuators:
1. Top Arrival (top_arrives): If the top lux sensor reads below 40 lx or the sun is below the horizon (used as a fallback since lux readings can lag right after lights turn off), turn on both the stair light (brightness 200, 6500 K) and the hallway switch.
2. Bottom Arrival (bottom_arrives): Turn on the stair light immediately without light level restrictions, as stairwells typically lack sufficient ambient light.
3. Top Departure (top_leaves): Turn off the hallway switch immediately. Turn off the stair light only if the bottom PIR sensor is also clear.
4. Bottom Departure (bottom_leaves): Turn off the stair light only if the top mmWave sensor is also clear.
To overcome occasional Zigbee delivery timeouts over mesh hops, wrap state transitions in repeat loops with template checks that retry up to three times.
- id: stairs_hallway_presence_lighting
alias: Stairs and Hallway Presence Lighting (Hybrid mmWave and PIR)
description: 'Controls stair light and hallway switch based on top mmWave and bottom PIR sensors, with light level check and retry loops.'
triggers:
- trigger: state
entity_id: binary_sensor.stairs_top_presence
to: 'on'
id: top_arrives
- trigger: state
entity_id: binary_sensor.stairs_top_presence
to: 'off'
id: top_leaves
- trigger: state
entity_id: binary_sensor.stairs_bottom_occupancy
to: 'on'
id: bottom_arrives
- trigger: state
entity_id: binary_sensor.stairs_bottom_occupancy
to: 'off'
id: bottom_leaves
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id: top_arrives
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.stairs_top_illuminance
below: 40
- condition: state
entity_id: sun.sun
state: below_horizon
sequence:
- parallel:
- repeat:
sequence:
- action: light.turn_on
target:
entity_id: light.stairs_light
data:
brightness: 200
color_temp_kelvin: 6500
- wait_template: "{{ is_state('light.stairs_light', 'on') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('light.stairs_light', 'on') or repeat.index >= 3 }}"
- repeat:
sequence:
- action: switch.turn_on
target:
entity_id: switch.hallway_light
- wait_template: "{{ is_state('switch.hallway_light', 'on') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('switch.hallway_light', 'on') or repeat.index >= 3 }}"
- conditions:
- condition: trigger
id: bottom_arrives
sequence:
- repeat:
sequence:
- action: light.turn_on
target:
entity_id: light.stairs_light
data:
brightness: 200
color_temp_kelvin: 6500
- wait_template: "{{ is_state('light.stairs_light', 'on') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('light.stairs_light', 'on') or repeat.index >= 3 }}"
- conditions:
- condition: trigger
id: top_leaves
sequence:
- parallel:
- repeat:
sequence:
- action: switch.turn_off
target:
entity_id: switch.hallway_light
- wait_template: "{{ is_state('switch.hallway_light', 'off') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('switch.hallway_light', 'off') or repeat.index >= 3 }}"
- if:
- condition: state
entity_id: binary_sensor.stairs_bottom_occupancy
state: 'off'
then:
- repeat:
sequence:
- action: light.turn_off
target:
entity_id: light.stairs_light
- wait_template: "{{ is_state('light.stairs_light', 'off') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('light.stairs_light', 'off') or repeat.index >= 3 }}"
- conditions:
- condition: trigger
id: bottom_leaves
- condition: state
entity_id: binary_sensor.stairs_top_presence
state: 'off'
sequence:
- repeat:
sequence:
- action: light.turn_off
target:
entity_id: light.stairs_light
- wait_template: "{{ is_state('light.stairs_light', 'off') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('light.stairs_light', 'off') or repeat.index >= 3 }}"
mode: restartStep 6 · Implement the 15-Minute Stuck Sensor Safety Cutoff
My top mmWave sensor sometimes stays on "present" with nobody there: once for about an hour, and another time for more than three hours, with the lights on the whole time. The sensor was still reporting normally and the radio link was good, so it was not a lost message. I do not know the exact cause (I suspect something moving in front of it, or its settings), and the automation turned lights off only when a sensor said "clear", so nothing ever switched them off.
To safeguard against this, create a secondary failsafe automation. If the top mmWave sensor remains 'on' continuously for 15 minutes (or if either fixture has stayed illuminated for 15 minutes) while the bottom PIR sensor is confirmed 'off', the automation forcibly turns off both fixtures using the same 3-second retry loop. This does not alter lights turned on manually when no presence was detected.
- id: stairs_hallway_safety_timeout
alias: Stairs and Hallway Safety Timeout (Failsafe for Stuck mmWave)
description: 'Turns off stairs and hallway lights if top mmWave sensor remains continuously on for 15 minutes while bottom PIR is clear.'
triggers:
- trigger: state
entity_id: binary_sensor.stairs_top_presence
to: 'on'
for:
minutes: 15
- trigger: state
entity_id: light.stairs_light
to: 'on'
for:
minutes: 15
- trigger: state
entity_id: switch.hallway_light
to: 'on'
for:
minutes: 15
conditions:
- condition: state
entity_id: binary_sensor.stairs_top_presence
state: 'on'
- condition: state
entity_id: binary_sensor.stairs_bottom_occupancy
state: 'off'
actions:
- parallel:
- repeat:
sequence:
- action: light.turn_off
target:
entity_id: light.stairs_light
- wait_template: "{{ is_state('light.stairs_light', 'off') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('light.stairs_light', 'off') or repeat.index >= 3 }}"
- repeat:
sequence:
- action: switch.turn_off
target:
entity_id: switch.hallway_light
- wait_template: "{{ is_state('switch.hallway_light', 'off') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('switch.hallway_light', 'off') or repeat.index >= 3 }}"
mode: singleStep 7 · Walk-Test Transitions and Verify Mesh Topology
Reload automations in Home Assistant (automation.reload) and perform physical walk tests across both directions:
1. Ascend from the bottom: Confirm the stair light turns on in under 1 second. Ascend to the top, trigger the mmWave sensor, and confirm the hallway switch turns on. 2. Stand still: Stop on the stairs for 10-15 seconds; confirm the light remains on thanks to the 30-second fading time. 3. Depart: Leave the zone; verify the stair light turns off approximately 20-30 seconds after both sensors report vacancy.
Finally, inspect your Zigbee network map. Check that the no-neutral relay and battery sensors have established stable links (LQI > 50) with their parent routers, such as the permanently energized stair bulb.
[✓] Top arrival triggers stairs light + hallway relay when illuminance < 40 lx or sun below horizon
[✓] Bottom arrival triggers stairs light immediately
[✓] Standing still for 15s does not shut off lights (fading_time = 30s)
[✓] Leaving zone turns off hallway immediately and stairs light when both sensors are off
[✓] LQI of EndDevices with parent routers remains stable (> 50 LQI)
[✓] Manual execution of safety timeout successfully turns off lights when mmWave is simulated stuckTroubleshooting
Top mmWave sensor pairs successfully to Zigbee2MQTT but reports no data or values show null.
Check battery voltage; depleted batteries allow pairing but fail to power the radar and radio transmissions. Insert fresh batteries, wake the sensor by moving in front of it, and publish a configure request to 'zigbee2mqtt/bridge/request/device/configure' with '{"id": "Sensor Stairs Top"}'.
Smart bulb resets to factory defaults and drops off the Zigbee mesh unexpectedly.
Avoid rapid power interruptions. Quick repeated power cycles can trigger the Tuya factory reset. If dropped, pair the bulb close to the coordinator and move it back, then reapply 'do_not_disturb: true'.
Staircase light turns off while someone is standing still on the stairs.
Battery-powered mmWave sensors conserve energy by reducing static sensitivity. Wake the sensor and increase 'fading_time' from 15s to 30s via Zigbee2MQTT so short periods of immobility do not trigger vacancy.
Top mmWave sensor remains latched in 'present' state for hours, keeping lights illuminated.
First check that the safety cutoff automation (step 6) is enabled: it turns the lights off after 15 minutes even if the sensor is stuck. Then, while the sensor is awake, try a lower sensitivity (I went from 8 to 7), and make sure nothing that moves (a curtain, a fan, a plant) is in front of it. I am still observing whether that is enough.
No-neutral relay in the wall box intermittently fails to turn on or off.
No-neutral relays act as EndDevices and cannot route messages. If their parent router has a weak signal through wall masonry, packets will drop. Ensure command retry loops are active in the automation, or install a dedicated mains-powered Zigbee repeater within 1 to 2 meters of the switch box.
What I learned
- Battery-powered Tuya mmWave sensors paired with weak batteries can end up in a half-configured state where they join the network but never transmit data; replacing batteries and triggering a device reconfigure while awake resolves it without needing a full re-pair.
- Rapid power cycling during electrical installation or loose socket contacts can inadvertently trigger the factory reset sequence of smart bulbs (like Tuya TS0505B), wiping settings and dropping them from the Zigbee mesh.
- Zigbee EndDevices (such as battery sensors and no-neutral wall relays) cannot route messages and depend strictly on a single parent router; losing that parent causes temporary disconnections until child devices re-associate.
- A battery mmWave sensor can stay on "present" for hours with nobody there. After it happened I lowered its sensitivity from 8 to 7 and added the safety cutoff. The cutoff has been tested; whether sensitivity 7 solves the root cause is still unknown.
- Zigbee radio commands in multi-vendor meshes occasionally experience timeouts; wrapping light control actions in repeat loops with template state checks ensures commands arrive reliably.
Next steps
- Add a dedicated mains-powered Zigbee plug or repeater close to wall-box relays to eliminate delivery failures and provide a reliable parent node.
- Experiment with physical directional shielding (such as placing metal or foil barriers around the sensor body) to constrain the radar beam strictly to the staircase.
- Evaluate long-term battery lifespan between rechargeable NiMH (1.2V) and standard alkaline (1.5V) cells in the mmWave radar unit.
Get the code
Home Assistant automations and Zigbee2MQTT configuration templates for hybrid mmWave and PIR presence lighting.
Files in the repository (3)
README.md
# Hybrid mmWave and PIR Presence Lighting
This project provides Home Assistant automations and Zigbee2MQTT configurations for a reliable, multi-sensor presence lighting system designed for staircases and connecting corridors.
## Overview
- **Hybrid Detection**: Combines a battery mmWave radar sensor (high sensitivity, detects stationary occupants) at the top landing with a fast-acting PIR motion sensor at the bottom landing.
- **Ambient Light Check**: Activates hallway lighting only when ambient lux is low or after sunset, while keeping stair lighting responsive at all times.
- **Mesh Reliability**: Uses retry loops on light commands to overcome occasional Zigbee packet drops.
- **Stuck Sensor Failsafe**: Automatically turns off lighting after 15 minutes if the mmWave sensor becomes stuck in a 'present' state while the PIR sensor is clear.
## Hardware Tested
- **Zigbee Coordinator**: Sonoff ZBDongle-E
- **Stair Light**: Tuya TS0505B Zigbee smart bulb (Router)
- **Hallway Relay**: Sonoff ZBMini-L2 no-neutral relay (EndDevice)
- **Top Sensor**: Tuya TS0601 mmWave radar sensor with illuminance (EndDevice, battery-powered)
- **Bottom Sensor**: Sonoff SNZB-03P PIR motion sensor (EndDevice, battery-powered)
## Configuration Files
- `automations.yaml`: Contains the primary hybrid automation (`stairs_hallway_presence_lighting`) and the safety timeout automation (`stairs_hallway_safety_timeout`).
- `zigbee2mqtt_device_settings.yaml`: Suggested device parameters for Zigbee2MQTT (`fading_time`, `sensitivity`, `motion_timeout`, and power defaults).
## Usage
1. Pair devices in Zigbee2MQTT and standardize your entity IDs to match `automations.yaml` (or adjust the entity IDs in the YAML to match your existing setup).
2. Apply the recommended device options in Zigbee2MQTT while sensors are awake.
3. Add the contents of `automations.yaml` to your Home Assistant configuration and reload automations.automations.yaml
- id: stairs_hallway_presence_lighting
alias: Stairs and Hallway Presence Lighting (Hybrid mmWave and PIR)
description: 'Controls stair light and hallway switch based on top mmWave and bottom PIR sensors, with light level check and retry loops.'
triggers:
- trigger: state
entity_id: binary_sensor.stairs_top_presence
to: 'on'
id: top_arrives
- trigger: state
entity_id: binary_sensor.stairs_top_presence
to: 'off'
id: top_leaves
- trigger: state
entity_id: binary_sensor.stairs_bottom_occupancy
to: 'on'
id: bottom_arrives
- trigger: state
entity_id: binary_sensor.stairs_bottom_occupancy
to: 'off'
id: bottom_leaves
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id: top_arrives
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.stairs_top_illuminance
below: 40
- condition: state
entity_id: sun.sun
state: below_horizon
sequence:
- parallel:
- repeat:
sequence:
- action: light.turn_on
target:
entity_id: light.stairs_light
data:
brightness: 200
color_temp_kelvin: 6500
- wait_template: "{{ is_state('light.stairs_light', 'on') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('light.stairs_light', 'on') or repeat.index >= 3 }}"
- repeat:
sequence:
- action: switch.turn_on
target:
entity_id: switch.hallway_light
- wait_template: "{{ is_state('switch.hallway_light', 'on') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('switch.hallway_light', 'on') or repeat.index >= 3 }}"
- conditions:
- condition: trigger
id: bottom_arrives
sequence:
- repeat:
sequence:
- action: light.turn_on
target:
entity_id: light.stairs_light
data:
brightness: 200
color_temp_kelvin: 6500
- wait_template: "{{ is_state('light.stairs_light', 'on') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('light.stairs_light', 'on') or repeat.index >= 3 }}"
- conditions:
- condition: trigger
id: top_leaves
sequence:
- parallel:
- repeat:
sequence:
- action: switch.turn_off
target:
entity_id: switch.hallway_light
- wait_template: "{{ is_state('switch.hallway_light', 'off') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('switch.hallway_light', 'off') or repeat.index >= 3 }}"
- if:
- condition: state
entity_id: binary_sensor.stairs_bottom_occupancy
state: 'off'
then:
- repeat:
sequence:
- action: light.turn_off
target:
entity_id: light.stairs_light
- wait_template: "{{ is_state('light.stairs_light', 'off') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('light.stairs_light', 'off') or repeat.index >= 3 }}"
- conditions:
- condition: trigger
id: bottom_leaves
- condition: state
entity_id: binary_sensor.stairs_top_presence
state: 'off'
sequence:
- repeat:
sequence:
- action: light.turn_off
target:
entity_id: light.stairs_light
- wait_template: "{{ is_state('light.stairs_light', 'off') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('light.stairs_light', 'off') or repeat.index >= 3 }}"
mode: restart
- id: stairs_hallway_safety_timeout
alias: Stairs and Hallway Safety Timeout (Failsafe for Stuck mmWave)
description: 'Turns off stairs and hallway lights if top mmWave sensor remains continuously on for 15 minutes while bottom PIR is clear.'
triggers:
- trigger: state
entity_id: binary_sensor.stairs_top_presence
to: 'on'
for:
minutes: 15
- trigger: state
entity_id: light.stairs_light
to: 'on'
for:
minutes: 15
- trigger: state
entity_id: switch.hallway_light
to: 'on'
for:
minutes: 15
conditions:
- condition: state
entity_id: binary_sensor.stairs_top_presence
state: 'on'
- condition: state
entity_id: binary_sensor.stairs_bottom_occupancy
state: 'off'
actions:
- parallel:
- repeat:
sequence:
- action: light.turn_off
target:
entity_id: light.stairs_light
- wait_template: "{{ is_state('light.stairs_light', 'off') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('light.stairs_light', 'off') or repeat.index >= 3 }}"
- repeat:
sequence:
- action: switch.turn_off
target:
entity_id: switch.hallway_light
- wait_template: "{{ is_state('switch.hallway_light', 'off') }}"
timeout:
seconds: 3
continue_on_timeout: true
until:
- condition: template
value_template: "{{ is_state('switch.hallway_light', 'off') or repeat.index >= 3 }}"
mode: singlezigbee2mqtt_device_settings.yaml
# Zigbee2MQTT device configurations
# Add these under the 'devices' section of your Zigbee2MQTT configuration.yaml
# or apply them via MQTT/frontend while battery devices are awake.
devices:
# Top mmWave radar sensor (Tuya TS0601 / _TZE284_gnpflcoq)
sensor_stairs_top:
friendly_name: "Sensor Stairs Top"
fading_time: 30 # seconds; 15 made the light switch off when standing still
sensitivity: 7 # 0-10; I started at 8, lowered to 7 after the sensor stayed "present" for hours (result still being observed)
# Bottom PIR motion sensor (Sonoff SNZB-03P)
sensor_pir_stairs_bottom:
friendly_name: "Sensor PIR Stairs Bottom"
motion_timeout: 20 # 20s clear time for fast stair transit reset
# Stair smart bulb (Tuya TS0505B)
stairs_light:
friendly_name: "Stairs Light"
do_not_disturb: true # Keeps bulb off if power is restored after an outage
# Hallway relay module (Sonoff ZBMini-L2)
hallway_light:
friendly_name: "Hallway Light"
power_on_behavior: "off"