/
light_auto_off.yaml
executable file
·88 lines (80 loc) · 2.16 KB
/
light_auto_off.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
blueprint:
name: Light Auto off
description: Turn off a light when no motion
domain: automation
input:
motion_entity:
name: Template motion Sensor
description: Template sensor - motion and light off
selector:
entity:
domain: binary_sensor
device_class: motion
light_off_entity:
name: Template motion Sensor
description: Template sensor - motion and light off
selector:
entity:
domain: binary_sensor
device_class: light
light_on_entity:
name: Template light sensor
description: Template sensor - no motion and light on
selector:
entity:
domain: binary_sensor
device_class: light
timer_entity:
name: Timer
description: Wait for motion
selector:
entity:
domain: timer
light_target:
name: Light
selector:
target:
entity:
domain: light
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
- platform: state
entity_id: !input light_on_entity
action:
choose:
# 1. Motion detected - lihgt on
- conditions:
- condition: state
entity_id: !input light_off_entity
state: 'on'
sequence:
- service: light.turn_on
target: !input light_target
# 2. No Motion and light turn on
- conditions:
- condition: state
entity_id: !input light_on_entity
state: 'on'
sequence:
- service: timer.start
entity_id: !input timer_entity
- wait_for_trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: !input timer_entity
- service: light.turn_off
target: !input light_target
# 3. No Motion and light turn off
- conditions:
- condition: state
entity_id: !input light_on_entity
state: 'off'
sequence:
- service: timer.cancel
entity_id: !input timer_entity