Home Assistant Master/Slave Motion Automation
Tested Configurations
- Single Master + multiple Slaves (mixed light/switch)
- Shared timer (one timer for both Master and Slave)
- Day/Night mode with inverted sensor
- Slave ignore list with partial day/night compliance
- Motion sensor unavailable scenarios
If you found this drawing helpful, please support the author by clicking the Like button (
) below.
GitHub Link Click
A universal blueprint for managing light and switch entities with comprehensive fail-safe protection based on motion sensors and timers. Devices of the type (light or switch) can be used as master devices. Mixed devices of the same type (light and switch) can be used as slave devices at once.
CORE LOGIC
Motion Delays
Pre-motion delay:
- Motion confirmation delay
motion_onevent is processed only if the sensor remains inonstate continuously for the specified time- Protection against false triggers from brief signals
Post-motion delay:
- Motion end confirmation delay
motion_offevent is processed with a delay, timers start only after it expires- Prevents lights from turning off during brief motion gaps
Master Device
- Automatically turns on when motion detected if:
Motion Control = ON (auto-on enabled)
Night Mode is active (or
Day/Night Mode is off)
- When motion stops, starts Master timer if Master is on
- Manual Master turn-on WITHOUT motion ALWAYS starts Master timer
- Manual Master turn-off:
- Stops Master timer
- Turns off all Slaves if synchronization is enabled
Auto-on by motion:
- Master turns on automatically
- Slaves turn on automatically ONLY if:
- Sync
is enabled - All Slaves are off
- Night/Day mode allows it
Motion Control = ON
- Sync
Slave Devices
- Slave timer is shared: one timer manages all Slaves simultaneously
- When a Slave turns on (with sync enabled), automatically turns on Master if it was off
- Manual Slave turn-on without motion starts Slave timer (only if sync is disabled)
- When sync is enabled:
- ALL other Slaves turn on, except the one that triggered the event
- Slave timer is not used (only Master timer works)
- Manual Slave turn-off:
- Does NOT turn off Master
- If Master is off and all Slaves are off, active timer stops
- Slave timer responds to motion: timer cancels when motion detected
Timer Logic
- Master and Slave timers start only when in idle state (not active)
- Timers stop when motion detected or devices manually turned off
- Master timer turns off Master and ALL active Slaves (with sync or shared timer)
- Slave timer is shared for all Slaves and turns off ALL active Slaves simultaneously
Timers ALWAYS work, regardless of day/night mode!
Day/Night Mode (optional)
| Mode | Motion | Auto-on | Action |
|---|---|---|---|
| Yes | Lights donβt turn on | ||
| No | - | ||
| Yes | Lights turn on | ||
| No | - |
Mode switching:
- Day β Night, motion present β lights TURN ON

- Night β Day, motion present β lights TURN OFF

- Night β Day, no motion β lights TURN OFF

Example night_sensor placeholder:
template: - binary_sensor: - name: βNight Alwaysβ unique_id: night_always state: β{{ false }}β availability: β{{ true }}β state: β{{ false }}β - Always Night (OFF)
auto-on enabled state: β{{ true }}β - Always Day (ON)
auto-on disabled
Fail-safe Protection If motion sensor becomes unavailable or unknown while Master or any Slave remains on, the corresponding timer starts
Additional periodic check every 5 minutes
Features Supports any number of Slave devices
Slaves can be mixed domains (light and switch)
Two independent delays: turn-on debounce (debounce_no_motion) and turn-off debounce (debounce_after_motion)
All service calls execute only when target entities exist
Timer Flexibility One timer for Master and Slave β use the SAME timer helper in both fields!
Master timer turns off Master and Slaves (with sync)
Slave timer turns off only Slaves
Works even without synchronization!
Simply specify one entity in:
Master Timer
Slave Timer
Mode Control
Interaction between π§ Motion Control and π Day/Night Mode:
| Motion | Result | ||
|---|---|---|---|
| Yes | |||
| No | |||
| Yes | |||
| Yes | |||
| Any | Yes | ||
| Any | No |
Important:
π§ Motion Control = OFFcompletely disables automation, but manual control and timers work normally- When Day/Night mode changes, lights sync with motion (even if
π§ Motion Control = OFF)
Ignoring Time of Day for Slaves
This feature allows specific Slaves to work independently of day/night mode.
| Situation | Result | ||
|---|---|---|---|
| Slave in list | Always works | ||
| Slave NOT in list | Follows day/night | ||
| Any Slave | Any |
IMPORTANT: This option is only available when
Sync = OFF
I made it for myself, the program includes Russian language.
If you found this drawing helpful, please support the author by clicking the Like button (
) below.