Reliable motion trigger

Reliable Motion Trigger

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

Source: GitHub - mimoSK/Reliable-motion-trigger: Home assistant blueprint for reliable light/switch controll. · GitHub

Reliable Motion Trigger is a Home Assistant automation blueprint for dependable motion-based lighting and switch control.
It is designed to reduce stuck states, recover from transient failures, and provide clear failure feedback when devices do not respond as expected.
Useful when your lights or switches are not reliable due to signal losses or other factors.
If you found your lights turned on when they shouldn’t be or vice versa, feel free to try this blueprint.

What This Blueprint Does

  • Turns one or more lights and/or switches on when motion is detected.
  • Turns targets off after a configurable no-motion delay.
  • Supports multiple occupancy sensors and multiple targets.
  • Optionally only turns on when illuminance is below a threshold.
  • Optionally blocks motion-based turn-on during a selected time window.
  • Retries turn-on and turn-off actions with configurable limits and delays.
  • Handles sensor unavailability safely.
  • Can run custom failure actions with useful template variables.

Required Entities

  • One or more occupancy sensors:
    • binary_sensor with device_class: occupancy
  • One or more target entities:
    • light and/or switch

Optional:

  • Illuminance sensor:
    • sensor with device_class: illuminance

How It Works

  1. Motion on trigger:

    • Checks that motion is active.
    • Optionally checks illuminance threshold and time-window block.
    • Applies optional custom turn-on conditions.
    • Retries turn on until success, motion stops, or retry limit is reached.
  2. Motion off trigger (with wait_time):

    • When no monitored motion sensor reports occupancy, retries turn off until success, or retry limit is reached.
  3. Motion sensor unavailable trigger:

    • If a sensor(s) becomes unavailable and no monitored sensor reports motion, runs the same turn-off branch.
  4. Failure handling:

    • If targets cannot reach the expected final state, optional custom failure actions are executed.

Inputs

Mandatory

  • Motion Sensor(s): One or more occupancy sensors.
  • Target Light(s) or Switch(es): One or more lights/switches to control.
  • Wait Time: Seconds to wait after motion stops before turning off.

Optional Turn-On Guards

  • Illuminance Sensor: Illuminance sensor used to gate turn-on.
  • Illuminance Threshold: Turn-on allowed only below this lux value.
  • Disable Turn-On During Time Window: Enable/disable time-window block.
  • Disable Turn-On Start Time: Start time for turn-on block.
  • Disable Turn-On End Time: End time for turn-on block.
  • Additional Turn-On Conditions: Additional custom conditions for turn-on.

Reliability

  • Retry Limit (On): Number of on retries.
  • Retry Delay (On): Delay between on retries.
  • Retry Limit (Off): Number of off retries.
  • Retry Delay (Off): Delay between off retries.

Failure Action

  • On Failure Action: Optional action sequence run when expected state is not achieved.

Available templates in failure_notification:

  • {{ attempted_state }}: On or Off
  • {{ target_id }}: Target entity ID(s)
  • {{ max_attempts_on }}: Configured turn-on retry limit
  • {{ max_attempts_off }}: Configured turn-off retry limit
  • {{ failed_turn_on_targets }}: Friendly names that failed to turn on
  • {{ failed_turn_off_targets }}: Friendly names that failed to turn off
  • {{ failed_turn_on_target_ids }}: Entity IDs that failed to turn on
  • {{ failed_turn_off_target_ids }}: Entity IDs that failed to turn off

Importing the Blueprint

Option 1: Use “Import blueprint” badge

  1. Click on “Import blueprint” badge which is at the top of this document.
  2. Follow the import instructions.

Option 2: Local file import

  1. Copy reliable-motion-trigger.yaml into your Home Assistant blueprints path, for example:
    • config/blueprints/automation/<your_namespace>/reliable-motion-trigger.yaml
  2. Reload automations/blueprints from Home Assistant.
  3. Create an automation from this blueprint.

Notes

  • This blueprint uses mode: restart so new triggers can supersede previous runs.