Skip to content

Instantly share code, notes, and snippets.

@arthursoares
Created November 2, 2025 17:18
Show Gist options
  • Select an option

  • Save arthursoares/d2e90e530a343893099a9c4e80631488 to your computer and use it in GitHub Desktop.

Select an option

Save arthursoares/d2e90e530a343893099a9c4e80631488 to your computer and use it in GitHub Desktop.
motion_sensor.yaml
blueprint:
name: Motion-activated Targets (Day vs. Quiet/Sleep)
description: >
Turn on one target on motion during the day, and a different target during a quiet time window
or when a Sleep-mode helper is ON. Turns the same target off after no motion.
domain: automation
author: You + Home Assistant
source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml
input:
motion_entity:
name: Motion Sensor
selector:
entity:
filter:
- domain: binary_sensor
device_class: motion
- domain: binary_sensor
device_class: occupancy
day_target:
name: Day target (entities to toggle on motion)
selector:
target: {}
quiet_target:
name: Quiet/Sleep target (entities to toggle when quiet time or Sleep mode)
selector:
target: {}
sleep_mode_helper:
name: Sleep mode helper (input_boolean)
description: Turn this ON to force quiet behavior regardless of time.
selector:
entity:
filter:
- domain: input_boolean
quiet_start:
name: Quiet time starts
selector:
time: {}
quiet_end:
name: Quiet time ends
selector:
time: {}
no_motion_wait:
name: Wait time after last motion
description: Seconds to keep target on after motion ends.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
# Restart on new motion
mode: restart
max_exceeded: silent
triggers:
- trigger: state
entity_id: !input motion_entity
from: "off"
to: "on"
actions:
- choose:
- conditions:
- condition: or
conditions:
- condition: state
entity_id: !input sleep_mode_helper
state: "on"
- condition: time
after: !input quiet_start
before: !input quiet_end
sequence:
- alias: "Quiet/Sleep: turn on"
action: homeassistant.turn_on
target: !input quiet_target
- alias: "Wait for no motion (Quiet/Sleep)"
wait_for_trigger:
- trigger: state
entity_id: !input motion_entity
from: "on"
to: "off"
- alias: "Delay off (Quiet/Sleep)"
delay:
seconds: !input no_motion_wait
- alias: "Quiet/Sleep: turn off"
action: homeassistant.turn_off
target: !input quiet_target
default:
- alias: "Day: turn on"
action: homeassistant.turn_on
target: !input day_target
- alias: "Wait for no motion (Day)"
wait_for_trigger:
- trigger: state
entity_id: !input motion_entity
from: "on"
to: "off"
- alias: "Delay off (Day)"
delay:
seconds: !input no_motion_wait
- alias: "Day: turn off"
action: homeassistant.turn_off
target: !input day_target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment