forked from myGithub-Markus/home-assistant_blueprints
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmotion_aware_entities.yaml
123 lines (118 loc) · 4.29 KB
/
motion_aware_entities.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
blueprint:
name: Motion aware entities toggling
description: >
Turn a entity on and off based on detected motion but only if certain criteria a matched provided by a Illuminance-Sensor.
Also allows to disable motion aware entities. This might be useful for example if a person is in the bed or a movie is playing.
domain: automation
input:
motion_sensor:
name: Motion Sensor
description: This sensor will be synchronized with the entities.
selector:
entity:
domain: binary_sensor
device_class: motion
no_motion_wait:
name: Wait time
description: Time to wait until the entities should be turned off.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
illuminance_sensor:
name: Illuminance Sensor
description: "Sensor that decides if entities should be turned on based on the illuminance."
selector:
entity:
domain: sensor
device_class: illuminance
illuminance_threshold:
name: Illumincance Threshold (Optional)
description: "Defines the illumincance threshold below which the entities should turn on."
default: 300
selector:
number:
min: 0
max: 100000
unit_of_measurement: lux
entity_blocker:
name: Entity Blocker
description: "Input Boolean that decides if entities shall not be interacted with - state on is do not turn on entities."
selector:
entity:
domain: input_boolean
motion_activated:
name: Motion activated
description: "Input Boolean that shows if the entities was turned on via motion"
selector:
target:
entity:
domain: input_boolean
disabled_entity:
name: Disabled Mode (Optional)
description: "Input Boolean that decides if entities shall not be interacted with - state on is do not turn on entities."
default:
selector:
entity:
domain: input_boolean
target_entity:
name: Entity
description: "The Entity to keep in sync."
selector:
entity:
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input motion_sensor
to: 'on'
- platform: state
entity_id: !input illuminance_sensor
- platform: state
entity_id: !input entity_blocker
to: 'on'
variables:
illuminance_sensor: !input illuminance_sensor
illuminance_threshold: !input illuminance_threshold
entity_blocker: !input entity_blocker
disabled_entity: !input disabled_entity
target_entity: !input target_entity
entity_domain: "{{ states[target_entity].domain }}"
condition:
- "{{ disabled_entity == none or is_state(disabled_entity, 'off') }}"
action:
- choose:
- conditions:
- "{{ entity_blocker == none or is_state(entity_blocker, 'off') }}"
- "{{ illuminance_sensor != none and states(illuminance_sensor)|int > illuminance_threshold|int }}"
- condition: state
entity_id: !input motion_sensor
state: 'on'
sequence:
- service: input_boolean.turn_off
target: !input motion_activated
- service: "{{entity_domain}}.turn_off"
entity_id: !input target_entity
- conditions:
- "{{ entity_blocker == none or is_state(entity_blocker, 'off') }}"
- "{{ illuminance_sensor != None and states(illuminance_sensor)|int < illuminance_threshold|int }}"
- condition: state
entity_id: !input motion_sensor
state: 'on'
sequence:
- service: input_boolean.turn_on
target: !input motion_activated
- service: "{{entity_domain}}.turn_on"
entity_id: !input target_entity
- wait_for_trigger:
platform: state
entity_id: !input motion_sensor
from: 'on'
to: 'off'
- delay: !input no_motion_wait
- service: input_boolean.turn_off
target: !input motion_activated
- service: "{{entity_domain}}.turn_off"
entity_id: !input target_entity