πŸ”₯ Master/Slave Fan Mixed devices (light and switch) Motion Fail-safe Timers

Home Assistant Master/Slave Motion Automation

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Version Status Home Assistant License

:test_tube: 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 (:heart:) below.

:link: 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.

:star: CORE LOGIC

:one: Motion Delays

:hourglass_flowing_sand: Pre-motion delay:

  • Motion confirmation delay
  • motion_on event is processed only if the sensor remains in on state continuously for the specified time
  • Protection against false triggers from brief signals

:hourglass_flowing_sand: Post-motion delay:

  • Motion end confirmation delay
  • motion_off event is processed with a delay, timers start only after it expires
  • Prevents lights from turning off during brief motion gaps

:two: Master Device

  • Automatically turns on when motion detected if:
    • :person_standing: Motion Control = ON (auto-on enabled)
    • :last_quarter_moon_with_face: Night Mode is active (or :high_brightness: 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
  • :zap: Auto-on by motion:
    • Master turns on automatically
    • Slaves turn on automatically ONLY if:
      • Sync :arrows_counterclockwise: is enabled
      • All Slaves are off
      • Night/Day mode allows it
      • :person_standing: Motion Control = ON

:three: 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

:four: 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
  • :warning: Timers ALWAYS work, regardless of day/night mode!

:five: Day/Night Mode (optional)

Mode Motion Auto-on Action
:sunny: Day Yes :x: Disabled Lights don’t turn on
:sunny: Day No :x: Disabled -
:crescent_moon: Night Yes :white_check_mark: Enabled Lights turn on
:crescent_moon: Night No :white_check_mark: Enabled -

:arrows_counterclockwise: Mode switching:

  • Day β†’ Night, motion present β†’ lights TURN ON :white_check_mark:
  • Night β†’ Day, motion present β†’ lights TURN OFF :white_check_mark:
  • Night β†’ Day, no motion β†’ lights TURN OFF :white_check_mark:

:wrench: Example night_sensor placeholder:

template: - binary_sensor: - name: β€œNight Always” unique_id: night_always state: β€œ{{ false }}” availability: β€œ{{ true }}” state: β€œ{{ false }}” - Always Night (OFF) :white_check_mark: auto-on enabled state: β€œ{{ true }}” - Always Day (ON) :x: auto-on disabled

:six: 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

:seven: 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

:eight: :bulb: Timer Flexibility One timer for Master and Slave β€” use the SAME timer helper in both fields!

:white_check_mark: Master timer turns off Master and Slaves (with sync)

:white_check_mark: Slave timer turns off only Slaves

:zap: Works even without synchronization!

:wrench: Simply specify one entity in:

:stopwatch: Master Timer

:timer_clock: Slave Timer

:nine: :electric_plug: Mode Control

Interaction between 🧍 Motion Control and πŸ”† Day/Night Mode:

:person_standing: Motion Control :high_brightness: Day/Night Mode Motion Result
:white_check_mark: ON :x: OFF Yes :white_check_mark: Lights always turn on
:white_check_mark: ON :x: OFF No :x: Timer starts
:white_check_mark: ON :white_check_mark: ON (Day) Yes :x: Lights DON’T turn on
:white_check_mark: ON :white_check_mark: ON (Night) Yes :white_check_mark: Lights turn on
:x: OFF Any Yes :x: Lights DON’T turn on
:x: OFF Any No :x: Only timers from manual on

Important:

  • 🧍 Motion Control = OFF completely disables automation, but manual control and timers work normally
  • When Day/Night mode changes, lights sync with motion (even if 🧍 Motion Control = OFF)

:keycap_ten: :no_bell: Ignoring Time of Day for Slaves

This feature allows specific Slaves to work independently of day/night mode.

Situation :arrows_counterclockwise: Sync :no_bell: Ignore Result
Slave in list :x: OFF :white_check_mark: In list Always works
Slave NOT in list :x: OFF :x: Not in list Follows day/night
Any Slave :white_check_mark: ON Any :x: DOESN’T WORK (all as group)

:pushpin: IMPORTANT: This option is only available when :arrows_counterclockwise: 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 (:heart:) below.

2 Likes

This is really cool, thank you for sharing. Out of interest, what hardware have you tried it on?

mapping values are not allowed here in β€œβ€, line 35, column 28: --tab-size-preference: 4; ^