Reliable Motion Trigger
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_sensorwithdevice_class: occupancy
- One or more target entities:
lightand/orswitch
Optional:
- Illuminance sensor:
sensorwithdevice_class: illuminance
How It Works
-
Motion
ontrigger:- 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.
-
Motion
offtrigger (withwait_time):- When no monitored motion sensor reports occupancy, retries turn off until success, or retry limit is reached.
-
Motion sensor
unavailabletrigger:- If a sensor(s) becomes unavailable and no monitored sensor reports motion, runs the same turn-off branch.
-
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 }}:OnorOff{{ 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
- Click on “Import blueprint” badge which is at the top of this document.
- Follow the import instructions.
Option 2: Local file import
- Copy
reliable-motion-trigger.yamlinto your Home Assistant blueprints path, for example:config/blueprints/automation/<your_namespace>/reliable-motion-trigger.yaml
- Reload automations/blueprints from Home Assistant.
- Create an automation from this blueprint.
Notes
- This blueprint uses
mode: restartso new triggers can supersede previous runs.