Skip to content

Instantly share code, notes, and snippets.

@tyrm
Last active July 18, 2025 18:56
Show Gist options
  • Select an option

  • Save tyrm/231a59e942278bae5a91d1356a5f8ccd to your computer and use it in GitHub Desktop.

Select an option

Save tyrm/231a59e942278bae5a91d1356a5f8ccd to your computer and use it in GitHub Desktop.
PupHaus Motion Sensor
blueprint:
name: PupHaus Motion Sensor
description: Turn on lights/scenes/scripts when motion is detected and turn them off after a delay when motion stops
domain: automation
input:
motion_sensor:
name: Motion Sensor
description: Binary sensor that detects motion
selector:
entity:
domain: binary_sensor
delay_minutes:
name: Delay (minutes)
description: Time to wait after motion stops before turning off
default: 5
selector:
number:
min: 0
max: 60
unit_of_measurement: minutes
automation_level:
name: Automation Level Input Select
description: Input select entity for automation level
selector:
entity:
domain: input_select
# Turn On Actions
turn_on_light:
name: Light to Turn On (Optional)
description: Light entity to turn on when motion is detected
default:
selector:
entity:
domain: light
turn_on_scene:
name: Scene to Activate (Optional)
description: Scene to activate when motion is detected
default:
selector:
entity:
domain: scene
turn_on_script:
name: Script to Run (Optional)
description: Script to run when motion is detected
default:
selector:
entity:
domain: script
# Turn Off Actions
turn_off_light:
name: Light to Turn Off (Optional)
description: Light entity to turn off when motion stops
default:
selector:
entity:
domain: light
turn_off_scene:
name: Scene to Activate for Off (Optional)
description: Scene to activate when motion stops
default:
selector:
entity:
domain: scene
turn_off_script:
name: Script to Run for Off (Optional)
description: Script to run when motion stops
default:
selector:
entity:
domain: script
variables:
turn_on_light: !input turn_on_light
turn_on_scene: !input turn_on_scene
turn_on_script: !input turn_on_script
turn_off_light: !input turn_off_light
turn_off_scene: !input turn_off_scene
turn_off_script: !input turn_off_script
trigger:
- platform: state
entity_id: !input motion_sensor
from: "off"
to: "on"
condition:
- condition: or
conditions:
- condition: state
entity_id: !input automation_level
state: "Full Auto"
- condition: state
entity_id: !input automation_level
state: "Semi Auto"
action:
# Turn on actions
- if:
- condition: template
value_template: "{{ turn_on_light not in ['', none, 'none'] }}"
then:
- service: light.turn_on
data:
transition: 1
target:
entity_id: !input turn_on_light
- if:
- condition: template
value_template: "{{ turn_on_scene not in ['', none, 'none'] }}"
then:
- service: scene.turn_on
target:
entity_id: !input turn_on_scene
- if:
- condition: template
value_template: "{{ turn_on_script not in ['', none, 'none'] }}"
then:
- service: script.turn_on
target:
entity_id: !input turn_on_script
# Wait for motion to stop
- wait_for_trigger:
- platform: state
entity_id: !input motion_sensor
from: "on"
to: "off"
# Delay
- delay:
minutes: !input delay_minutes
# Check conditions again
- condition: or
conditions:
- condition: state
entity_id: !input automation_level
state: "Full Auto"
- condition: state
entity_id: !input automation_level
state: "Semi Auto"
# Turn off actions
- if:
- condition: template
value_template: "{{ turn_off_light not in ['', none, 'none'] }}"
then:
- service: light.turn_off
target:
entity_id: !input turn_off_light
- if:
- condition: template
value_template: "{{ turn_off_scene not in ['', none, 'none'] }}"
then:
- service: scene.turn_on
target:
entity_id: !input turn_off_scene
- if:
- condition: template
value_template: "{{ turn_off_script not in ['', none, 'none'] }}"
then:
- service: script.turn_on
target:
entity_id: !input turn_off_script
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment