/
automations.yaml
193 lines (193 loc) · 4.46 KB
/
automations.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
- id: automation_living_room_lights
alias: Scene Living Room
initial_state: true
trigger:
platform: state
entity_id: input_select.scene_livingroom
action:
- service: hue.hue_activate_scene
data_template:
group_name: Living Room
scene_name: "{{ states('input_select.scene_livingroom') }}"
- id: automation_kitchen_lights
alias: Scene Kitchen
initial_state: true
trigger:
platform: state
entity_id: input_select.scene_kitchen
action:
- service: hue.hue_activate_scene
data_template:
group_name: Kitchen
scene_name: "{{ states('input_select.scene_kitchen') }}"
- id: automation_bedroom_lights
alias: Scene Bedroom
initial_state: true
trigger:
platform: state
entity_id: input_select.scene_bedroom
action:
- service: hue.hue_activate_scene
data_template:
group_name: Bedroom
scene_name: "{{ states('input_select.scene_bedroom') }}"
- id: sunset
alias: Sunset
trigger:
platform: sun
event: sunset
offset: -00:45:00
condition:
condition: state
entity_id: group.family
state: home
action:
- service: script.turn_on_lights
- id: night_lighting
alias: Night Lighting
trigger:
platform: time
at: 00:00:00
condition:
- condition: state
entity_id: group.family
state: home
- condition: state
entity_id: group.living_room_lights
state: "on"
action:
- service: hue.hue_activate_scene
data_template:
group_name: Bedroom
scene_name: Read
- service: hue.hue_activate_scene
data_template:
group_name: Kitchen
scene_name: Relax
initial_state: "on"
- id: ifttt_webhook
alias: IFTTT Webhook
trigger:
platform: event
event_type: ifttt_webhook_received
event_data:
action: call_service
action:
service_template: "{{ trigger.event.data.service }}"
data_template:
entity_id: "{{ trigger.event.data.entity_id }}"
- id: danny_away
alias: Danny Away
trigger:
- entity_id: input_boolean.danny_home
from: "on"
platform: state
to: "off"
action:
- service: device_tracker.see
data:
dev_id: danny
location_name: not_home
- id: danny_home
alias: Danny Home
trigger:
- entity_id: input_boolean.danny_home
from: "off"
platform: state
to: "on"
action:
- service: device_tracker.see
data:
dev_id: danny
location_name: home
initial_state: "on"
- id: maire_away
alias: Maire Away
trigger:
- entity_id: input_boolean.maire_home
from: "on"
platform: state
to: "off"
action:
- service: device_tracker.see
data:
dev_id: maire
location_name: not_home
- id: maire_home
alias: Maire Home
trigger:
- entity_id: input_boolean.maire_home
from: "off"
platform: state
to: "on"
action:
- service: device_tracker.see
data:
dev_id: maire
location_name: home
initial_state: "on"
# Occupancy logic
- id: occupied
alias: Occupied
initial_state: "on"
trigger:
- entity_id: group.family
from: not_home
platform: state
to: home
action:
- service: script.welcome_home
- id: unoccupied
alias: Unoccupied
initial_state: "on"
trigger:
- entity_id: group.family
from: home
platform: state
to: not_home
action:
- service: script.interior_off
# Sleeping logic
## First person to go to sleep has the lamp turn off
- id: turn_off_bed_lamp
alias: "Going to sleep"
initial_state: "on"
trigger:
- entity_id: input_boolean.danny_sleep
from: "off"
platform: state
to: "on"
- entity_id: input_boolean.maire_sleep
from: "off"
platform: state
to: "on"
action:
- service: light.turn_off
entity_id: light.bed_lamp
## Second person turns off the whole house
- id: going_to_sleep
alias: "Going to sleep"
initial_state: "on"
trigger:
- entity_id: input_boolean.danny_sleep
from: "off"
platform: state
to: "on"
- entity_id: input_boolean.maire_sleep
from: "off"
platform: state
to: "on"
condition:
# Both people should be sleeping
- condition: state
entity_id: input_boolean.danny_sleep
state: "on"
- condition: state
entity_id: input_boolean.maire_sleep
state: "on"
# We have to be home
- condition: state
entity_id: group.family
state: home
action:
- service: script.go_to_sleep