This is a generic blueprint meant to turn off things that were left on.
Fill in the
- Motion Detector
- Switch
- Stay On Time (minutes)
- Grace Period (minutes, 0 to disable)
- Delay before starting grace period (seconds)
and this blueprint will:
- Turn off the switch after it has been on, without the motion detector firing, for at least “Stay On Time”
- If, after turning off and waiting for “Arm Delay” second, motion is detected within “Grace Period” then the switch will turn back on.
blueprint:
name: Turn off unoccupied switches
source_url: https://gist.github.com/cobryan05/24f19bad93b642b7e0c5f8f1da0515d0
description: Turn off a switch that has been left on with no motion
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
switch_entity:
name: Switch
selector:
entity:
domain: switch
wait_time_selector:
name: Stay On Time
description: Time to keep switch on with no motion
default: 30
selector:
number:
min: 1
max: 1440
unit_of_measurement: minutes
grace_period_selector:
name: Grace Period
description: After turning off the switch, turn it back on if motion is detected within grace period
default: 30
selector:
number:
min: 0
max: 1440
unit_of_measurement: minutes
grace_arm_delay_selector:
name: Grace Arm Delay Period
description: Delay before starting grace period (to prevent the act of turning off the switch from triggering the sensor)
default: 2
selector:
number:
min: 0
max: 60
unit_of_measurement: seconds
mode: single
trigger:
- platform: state
entity_id: !input switch_entity
to: 'on'
for:
minutes: !input wait_time_selector
- platform: state
entity_id: !input motion_entity
to: 'off'
for:
minutes: !input wait_time_selector
condition:
- condition: state
entity_id: !input switch_entity
state: 'on'
for:
minutes: !input wait_time_selector
- condition: state
entity_id: !input motion_entity
state: 'off'
for:
minutes: !input wait_time_selector
action:
- service: switch.turn_off
entity_id: !input switch_entity
- delay:
seconds: !input grace_arm_delay_selector
- wait_for_trigger:
- platform: state
entity_id: !input motion_entity
to: 'on'
- platform: state
entity_id: !input switch_entity
to: 'on'
timeout:
minutes: !input grace_period_selector
continue_on_timeout: false
- service: switch.turn_on
entity_id: !input switch_entity