Skip to content

Instantly share code, notes, and snippets.

@thomaskonrad
Last active March 27, 2022 09:51
Show Gist options
  • Save thomaskonrad/6c5802ffbb18c0cc13b737821717a9e3 to your computer and use it in GitHub Desktop.
Save thomaskonrad/6c5802ffbb18c0cc13b737821717a9e3 to your computer and use it in GitHub Desktop.
A Home Assistant blueprint to automatically turn a fan on and off upon motion
blueprint:
name: Motion-activated Fan
description: A Home Assistant blueprint to automatically turn a fan on and off upon motion
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
fan_target:
name: Fan
selector:
target:
entity:
domain: switch
minimum_motion_duration:
name: Minimum motion duration
description: Number of seconds the motion needs to last for the fan to turn on
default: 10
selector:
number:
min: 0
max: 600
unit_of_measurement: seconds
no_motion_wait:
name: Wait time
description: Time to leave the fan on after last motion is detected.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
for:
seconds: !input minimum_motion_duration
action:
- service: switch.turn_on
target: !input fan_target
- wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
- delay: !input no_motion_wait
- service: switch.turn_off
target: !input fan_target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment