Skip to content

Instantly share code, notes, and snippets.

@Nitecon
Last active July 26, 2022 01:47
Show Gist options
  • Save Nitecon/77b0485080f63550b38d2bd3e91df904 to your computer and use it in GitHub Desktop.
Save Nitecon/77b0485080f63550b38d2bd3e91df904 to your computer and use it in GitHub Desktop.
Motion activated scenes for home assistant
blueprint:
name: Motion activated scenes
description: Activate a day/night scene when motion is detected. Without motion an off scene is triggered.
domain: automation
source_url: https://gist.github.com/Nitecon/77b0485080f63550b38d2bd3e91df904
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
multiple: true
scene_day:
name: Scene for the bright day
default: scene.none
selector:
entity:
domain: scene
time_scene_day:
name: Time for the day scene
description: A time input which defines the time from which on the scene will be activated if motion is detected. Default value = scene.none
default: "06:00:00"
selector:
time:
scene_night:
name: Scene for the dark night
default: scene.none
selector:
entity:
domain: scene
time_scene_night:
name: Time for the night scene
description: A time input which defines the time from which on the scene will be activated if motion is detectedd. Default value = scene.none
default: "20:00:00"
selector:
time:
scene_off:
name: Off Scene (Optional)
description: Scene for Off state. Will be activated when no motion is detected and light level is under threshold. Default value = scene.none
default: scene.none
selector:
entity:
domain: scene
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
mode: restart
max_exceeded: silent
variables:
scene_off: !input scene_off
trigger:
platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
action:
- choose:
- conditions:
- condition: time
after: !input time_scene_night
before: !input time_scene_day
sequence:
- scene: !input scene_night
- conditions:
- condition: time
after: !input time_scene_day
before: !input time_scene_night
sequence:
- scene: !input scene_day
- wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
- delay: !input no_motion_wait
- choose:
- conditions:
- "{{ scene_off != 'scene.none'}}"
sequence:
- scene: !input scene_off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment