-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathunderbed.yaml
297 lines (284 loc) · 6.91 KB
/
underbed.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
substitutions:
friendly_name: "Under Bed"
device_name: "underbed"
packages:
base: !include device-base.yaml
irk_locator: !include irk_locator.yaml
esp32:
board: esp32dev
framework:
type: arduino
ota:
light:
# - platform: fastled_clockless
# rgb_order: GRB
# chipset: WS2812B
# pin: GPIO25
# num_leds: 192
# name: "Under Bed Light"
# id: under_bed_light
# color_correct: [50%, 50%, 50%]
- platform: neopixelbus
type: GRB
variant: WS2812
pin: GPIO23
# method:
# type: esp32_rmt
num_leds: 192
name: "Under Bed Light"
id: under_bed_light
color_correct: [50%, 50%, 50%]
esp32_touch:
#setup_mode: true
# low_voltage_reference: 0.5V
# high_voltage_reference: 2.4V
# voltage_attenuation: 1.5V
# iir_filter: 50ms
binary_sensor:
- platform: esp32_touch
name: "David Feet"
pin: GPIO15
threshold: 8
id: david_feet
- platform: esp32_touch
name: "Middle Pillow"
pin: GPIO2
threshold: 5
id: middle_pillow
- platform: esp32_touch
name: "Aysylu Feet"
pin: GPIO4
threshold: 6
id: aysylu_feet
- platform: esp32_touch
name: "David Pillow"
pin: GPIO12
threshold: 8
id: david_pillow
- platform: esp32_touch
name: "Aysylu Pillow"
pin: GPIO13
threshold: 6
id: aysylu_pillow
- platform: esp32_touch
name: "Middle Feet"
pin: GPIO14
threshold: 6
id: middle_feet
- platform: template
name: "Aysylu's Side"
id: aysylu_side
lambda: |-
if (id(aysylu_feet).state ||
id(aysylu_pillow).state) {
return true;
} else {
return false;
}
filters:
- delayed_off: 30s
- platform: template
name: "David's Side"
id: david_side
lambda: |-
if (id(david_feet).state ||
id(david_pillow).state) {
return true;
} else {
return false;
}
filters:
- delayed_off: 30s
- platform: template
name: "Middle of Bed"
id: middle_side
lambda: |-
if (id(middle_feet).state ||
id(middle_pillow).state) {
return true;
} else {
return false;
}
filters:
- delayed_off: 30s
- platform: template
name: "Someone in Bed"
lambda: |-
if (id(david_side).state ||
id(middle_side).state ||
id(aysylu_side).state) {
return true;
} else {
return false;
}
- platform: template
name: "Both in Bed"
lambda: |-
if ((id(david_side).state &&
id(middle_side).state) ||
(id(aysylu_side).state &&
id(middle_side).state) ||
(id(aysylu_side).state &&
id(david_side).state)) {
return true;
} else {
return false;
}
- platform: gpio
pin:
number: GPIO19
mode:
input: true
name: "David PIR Under Bed"
id: david_pir
filters:
- delayed_off: 30s
on_press:
then:
- script.execute:
id: turn_on_underbed_light
activate: true
on_release:
then:
- script.execute:
id: turn_on_underbed_light
activate: false
- platform: gpio
pin:
number: GPIO21
mode:
input: true
name: "Aysylu PIR Under Bed"
id: aysylu_pir
filters:
- delayed_off: 30s
on_press:
then:
- script.execute:
id: turn_on_underbed_light
activate: true
on_release:
then:
- script.execute:
id: turn_on_underbed_light
activate: false
- platform: homeassistant
entity_id: input_boolean.dna_sleeping
id: ha_dna_sleeping
script:
- id: turn_on_underbed_light
mode: restart
parameters:
activate: bool
then:
- if:
condition:
binary_sensor.is_on: ha_dna_sleeping
then:
- if:
condition:
lambda: |-
return activate;
then:
- light.turn_on:
id: under_bed_light
brightness: 100%
red: 100%
green: 85%
blue: 0%
transition_length: 500ms
else:
- if:
condition:
and:
- binary_sensor.is_off: david_pir
- binary_sensor.is_off: aysylu_pir
then:
- light.turn_off:
id: under_bed_light
transition_length: 250ms
# number:
# - platform: template
# name: David Pillow Level
# id: david_pillow_level
# entity_category: config
# min_value: 1
# max_value: 20
# initial_value: 6
# optimistic: true
# step: 1
# restore_value: true
# mode: slider
# set_action:
# - lambda: |-
# id(david_pillow).set_threshold(id(david_pillow_level).state);
# - platform: template
# name: David Feet Level
# id: david_feet_level
# entity_category: config
# min_value: 1
# max_value: 20
# initial_value: 6
# optimistic: true
# step: 1
# restore_value: true
# mode: slider
# set_action:
# - lambda: |-
# id(david_feet).set_threshold(id(david_feet_level).state);
# - platform: template
# name: Aysylu Pillow Level
# id: aysylu_pillow_level
# entity_category: config
# min_value: 1
# max_value: 20
# initial_value: 6
# optimistic: true
# step: 1
# restore_value: true
# mode: slider
# set_action:
# - lambda: |-
# id(aysylu_pillow).set_threshold(id(aysylu_pillow_level).state);
# - platform: template
# name: Aysylu Feet Level
# id: aysylu_feet_level
# entity_category: config
# min_value: 1
# max_value: 20
# initial_value: 6
# optimistic: true
# step: 1
# restore_value: true
# mode: slider
# set_action:
# - lambda: |-
# id(aysylu_feet).set_threshold(id(aysylu_feet_level).state);
# - platform: template
# name: Middle Pillow Level
# id: middle_pillow_level
# entity_category: config
# min_value: 1
# max_value: 20
# initial_value: 6
# optimistic: true
# step: 1
# restore_value: true
# mode: slider
# set_action:
# - lambda: |-
# id(middle_pillow).set_threshold(id(middle_pillow_level).state);
# - platform: template
# name: Middle Feet Level
# id: middle_feet_level
# entity_category: config
# min_value: 1
# max_value: 20
# initial_value: 6
# optimistic: true
# step: 1
# restore_value: true
# mode: slider
# set_action:
# - lambda: |-
# id(middle_feet).set_threshold(id(middle_feet_level).state);