Skip to content

Instantly share code, notes, and snippets.

@DRuggeri
Last active July 8, 2023 14:50
Show Gist options
  • Save DRuggeri/1cde1525529358f40c6f139606e2329b to your computer and use it in GitHub Desktop.
Save DRuggeri/1cde1525529358f40c6f139606e2329b to your computer and use it in GitHub Desktop.
blueprint:
name: Motion Activated Anything
description: Execute on/off actions based on motion and timeout
domain: automation
source_url: https://gist.github.com/DRuggeri/1cde1525529358f40c6f139606e2329b
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class:
- motion
- occupancy
on_action:
name: Motion Detected Action
default: []
selector:
action:
off_action:
name: Motion Undetected Action
default: []
selector:
action:
no_motion_wait:
name: Wait time
description: Time to wait with no motion before triggering the off action
default: 300
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
action:
- choose:
- conditions: "{{ true }}"
sequence: !input on_action
- alias: "Wait until there is no motion from device"
wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
- alias: "Wait the number of seconds that has been set"
delay: !input no_motion_wait
- choose:
- conditions: "{{ true }}"
sequence: !input off_action
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment