-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmotion_action.yaml
63 lines (60 loc) · 1.6 KB
/
motion_action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
blueprint:
name: Motion-activated state
description: Do something to something
source_url: https://github.com/evorgevol/hassio/blob/main/motion_action.yaml
domain: automation
author: evorgevol
input:
motion_entity:
name: Motion Sensor
selector:
entity:
filter:
device_class: motion
domain: binary_sensor
action_motion:
name: (Optional) Action to run when motion detected
description: Action to run when motion detected
default: []
selector:
action: {}
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:
action_entities: !input action_motion
action_target: '{{ action_entities[0].target.entity_id }}'
trigger:
platform: state
entity_id: !input motion_entity
from: 'off'
to: 'on'
action:
- alias: 'Store previous state'
service: scene.create
data:
scene_id: evo_motion_active
snapshot_entities: '{{ action_target }}'
- choose:
- conditions: []
sequence: !input action_motion
- alias: 'Wait until there is no motion from device'
wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: 'on'
to: 'off'
- alias: 'Wait the number of seconds that has been set'
delay: !input no_motion_wait
- alias: 'Restore state'
service: scene.turn_on
target:
entity_id: scene.evo_motion_active