-
Notifications
You must be signed in to change notification settings - Fork 6
/
esp-lights-bathroom.yaml
308 lines (295 loc) · 7.96 KB
/
esp-lights-bathroom.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
298
299
300
301
302
303
304
305
306
307
308
substitutions:
node_name: esp-lights-bathroom
node_friendly_name: "Bathroom Vanity"
packages:
esp_common: !include shared/esp__common_core.yaml
esp32:
board: esp32dev
status_led:
pin:
number: 5
inverted: true
uart:
id: ld2420_uart
rx_pin: 4
tx_pin: 2
baud_rate: 115200
parity: NONE
stop_bits: 1
ld2420:
text_sensor:
- platform: ld2420
fw_version:
name: LD2420 Firmware
sensor:
- platform: ld2420
moving_distance:
name: Moving Distance
select:
- platform: ld2420
operating_mode:
name: Operating Mode
# template selects to control motion activation behavior of lights
- platform: template
id: bathroom_vanity_motion_activation_lower
name: Motion Activation Lower
entity_category: config
optimistic: true
options:
- Enabled
- Turn Off Only
- Disabled
initial_option: Enabled
restore_value: true
- platform: template
id: bathroom_vanity_motion_activation_upper
name: Motion Activation Upper
entity_category: config
optimistic: true
options:
- Enabled
- Turn Off Only
- Disabled
initial_option: Enabled
restore_value: true
number:
- platform: ld2420
presence_timeout:
name: Detection Presence Timeout
min_gate_distance:
name: Detection Gate Minimum
max_gate_distance:
name: Detection Gate Maximum
gate_move_sensitivity:
name: Move Calibration Sensitivity Factor
gate_still_sensitivity:
name: Still Calibration Sensitivity Factor
gate_0:
move_threshold:
name: Gate 0 Move Threshold
still_threshold:
name: Gate 0 Still Threshold
gate_1:
move_threshold:
name: Gate 1 Move Threshold
still_threshold:
name: Gate 1 Still Threshold
gate_2:
move_threshold:
name: Gate 2 Move Threshold
still_threshold:
name: Gate 2 Still Threshold
gate_3:
move_threshold:
name: Gate 3 Move Threshold
still_threshold:
name: Gate 3 Still Threshold
gate_4:
move_threshold:
name: Gate 4 Move Threshold
still_threshold:
name: Gate 4 Still Threshold
gate_5:
move_threshold:
name: Gate 5 Move Threshold
still_threshold:
name: Gate 5 Still Threshold
gate_6:
move_threshold:
name: Gate 6 Move Threshold
still_threshold:
name: Gate 6 Still Threshold
gate_7:
move_threshold:
name: Gate 7 Move Threshold
still_threshold:
name: Gate 7 Still Threshold
gate_8:
move_threshold:
name: Gate 8 Move Threshold
still_threshold:
name: Gate 8 Still Threshold
gate_9:
move_threshold:
name: Gate 9 Move Threshold
still_threshold:
name: Gate 9 Still Threshold
gate_10:
move_threshold:
name: Gate 10 Move Threshold
still_threshold:
name: Gate 10 Still Threshold
gate_11:
move_threshold:
name: Gate 11 Move Threshold
still_threshold:
name: Gate 11 Still Threshold
gate_12:
move_threshold:
name: Gate 12 Move Threshold
still_threshold:
name: Gate 12 Still Threshold
gate_13:
move_threshold:
name: Gate 13 Move Threshold
still_threshold:
name: Gate 13 Still Threshold
gate_14:
move_threshold:
name: Gate 14 Move Threshold
still_threshold:
name: Gate 14 Still Threshold
gate_15:
move_threshold:
name: Gate 15 Move Threshold
still_threshold:
name: Gate 15 Still Threshold
button:
- platform: ld2420
apply_config:
name: Apply Config
factory_reset:
name: Factory Reset
restart_module:
name: Restart Module
revert_config:
name: Undo Edits
binary_sensor:
# API status sensor
- platform: status
id: bathroom_vanity_api_status
name: API Status
internal: true
# motion sensor (via sensor nodule)
- platform: ld2420
has_target:
id: bathroom_vanity_motion_detection
name: Presence
on_press:
then:
# only switch the light based on the mode defined by the template select
- if:
condition:
lambda: |-
return id(bathroom_vanity_motion_activation_lower).state == "Enabled" || !id(bathroom_vanity_api_status).state;
then:
- light.turn_on: bathroom_vanity_downlight
# only switch the light based on the mode defined by the template select
- if:
condition:
lambda: |-
return id(bathroom_vanity_motion_activation_upper).state == "Enabled" || !id(bathroom_vanity_api_status).state;
then:
- light.turn_on: bathroom_vanity_uplight
on_release:
then:
# only switch the light based on the mode defined by the template select
- if:
condition:
lambda: |-
return id(bathroom_vanity_motion_activation_lower).state != "Disabled" || !id(bathroom_vanity_api_status).state;
then:
- light.turn_off: bathroom_vanity_downlight
# only switch the light based on the mode defined by the template select
- if:
condition:
lambda: |-
return id(bathroom_vanity_motion_activation_upper).state != "Disabled" || !id(bathroom_vanity_api_status).state;
then:
- light.turn_off: bathroom_vanity_uplight
# sensors for buttons for manual control of lights
- platform: gpio
id: bathroom_lights_off_button
pin:
number: 0
inverted: true
on_click:
min_length: 50ms
max_length: 500ms
then:
- light.turn_off:
id: bathroom_vanity_uplight
- light.turn_off:
id: bathroom_vanity_downlight
- platform: gpio
id: bathroom_vanity_uplight_on_button
pin:
number: 34
inverted: true
on_click:
min_length: 50ms
max_length: 500ms
then:
- light.turn_on:
id: bathroom_vanity_uplight
brightness: 1.0
red: 1.0
green: 0.933
blue: 0.753
white: 1.0
- platform: gpio
id: bathroom_vanity_downlight_on_button
pin:
number: 35
inverted: true
on_click:
min_length: 50ms
max_length: 500ms
then:
- light.turn_on:
id: bathroom_vanity_downlight
brightness: 0.5
red: 1.0
green: 0.933
blue: 0.753
white: 1.0
light:
- platform: rgbw
id: bathroom_vanity_downlight
name: Downlight
restore_mode: RESTORE_DEFAULT_OFF
red: bathroom_vanity_downlight_pwm_red_channel
green: bathroom_vanity_downlight_pwm_green_channel
blue: bathroom_vanity_downlight_pwm_blue_channel
white: bathroom_vanity_downlight_pwm_white_channel
effects:
- random:
- strobe:
- flicker:
- platform: rgbw
id: bathroom_vanity_uplight
name: Uplight
restore_mode: RESTORE_DEFAULT_OFF
red: bathroom_vanity_uplight_pwm_red_channel
green: bathroom_vanity_uplight_pwm_green_channel
blue: bathroom_vanity_uplight_pwm_blue_channel
white: bathroom_vanity_uplight_pwm_white_channel
effects:
- random:
- strobe:
- flicker:
output:
- platform: ledc
id: bathroom_vanity_downlight_pwm_red_channel
pin: 16
- platform: ledc
id: bathroom_vanity_downlight_pwm_green_channel
pin: 18
- platform: ledc
id: bathroom_vanity_downlight_pwm_blue_channel
pin: 13
- platform: ledc
id: bathroom_vanity_downlight_pwm_white_channel
pin: 27
- platform: ledc
id: bathroom_vanity_uplight_pwm_red_channel
pin: 25
- platform: ledc
id: bathroom_vanity_uplight_pwm_green_channel
pin: 26
- platform: ledc
id: bathroom_vanity_uplight_pwm_blue_channel
pin: 33
- platform: ledc
id: bathroom_vanity_uplight_pwm_white_channel
pin: 32