A goal of this, purposefully basic, blueprint is to for users who love the default “Motion-activated light” blueprint, but want to use switches too. I have elected to switch to an Entity selector instead of the Target selector used in the original (see note below for explanation).
Feel free to post any issues you discover, I will happily attempt to correct them. However, please do not post requests to add features… as stated, one of the primary goals of this blueprint is to keep simple and on par with the original.
2024-12-14:
- Corrected config error.
2024-12-21:
- Switched to independent triggers to avoid the Wait in the automation.
Note: Explanation of selector change
The use of Area and Device targets will effect all light
and/or switch
entities in the respective Area/Device. Because the original blueprint could only target lights, there was only a small chance that would have any substantial, negative effects. However, many devices and integrations create virtual switches to cover secondary functions. Haphazardly turning on and off functions like “reset” or “Do Not Disturb” could cause serious issues for users.
blueprint:
name: Motion-activated Light and Switch
description: Turn on a light and/or switch when motion is detected.
domain: automation
input:
motion_entity:
name: Motion or Occupancy Sensor
selector:
entity:
multiple: false
filter:
- device_class: occupancy
domain: binary_sensor
- device_class: motion
domain: binary_sensor
light_target:
name: Light
selector:
entity:
multiple: true
filter:
- domain:
- light
- switch
no_motion_wait:
name: Wait time
description: Number of seconds motion must be undetected for the light to be turned off.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
max_exceeded: silent
triggers:
- trigger: state
entity_id: !input motion_entity
from: "off"
to: "on"
id: "on"
- trigger: state
entity_id: !input motion_entity
from: "on"
to: "off"
for:
seconds: !input no_motion_wait
id: "off"
actions:
- alias: "Turn the light on or off based on motion trigger ID"
action: "homeassistant.turn_{{ trigger.id }}"
target:
entity_id: !input light_target