-
Notifications
You must be signed in to change notification settings - Fork 12
/
lightswitch.yaml
376 lines (344 loc) · 7.72 KB
/
lightswitch.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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
substitutions:
device_name: lightswitch
esphome:
name: lightswitch
friendly_name: lightswitch
external_components:
- source: github://ayufan/esphome-components
drv2605:
id: haptic
rated_voltage: 1.8V
resonant_frequency: 205Hz
esp32:
# board: wesp32
board: esp32-poe-iso
# framework:
# type: esp-idf
# version: recommended
framework:
type: arduino
# Enable logging
logger:
level: DEBUG
# Enable Home Assistant API
api:
ota:
password: ""
wifi:
ssid: 74ax4k
password: twosigma
#ethernet:
# type: LAN8720
# mdc_pin: GPIO23
# mdio_pin: GPIO18
# clk_mode: GPIO17_OUT
# phy_addr: 0
# power_pin: GPIO12
# manual_ip:
# static_ip: 192.168.20.70
# gateway: 192.168.20.1
# subnet: 255.255.255.0
# use_address: 192.168.20.70
i2c:
scl: GPIO16
sda: GPIO13
scan: true
id: i2c_bus
memory: # from ayufan/esphome-components; periodically prints free memory
i2s_audio:
# - id: i2s_mic
# i2s_lrclk_pin: GPIO4
- id: i2s_amp
i2s_lrclk_pin: GPIO2
i2s_bclk_pin: GPIO14
microphone:
- platform: i2s_audio
i2s_din_pin: GPIO35
adc_type: external
pdm: true
id: mic_id
# i2s_audio_id: i2s_mic
i2s_audio_id: i2s_amp
voice_assistant:
microphone: mic_id
speaker: amp_id
on_start:
then:
- output.turn_on: amp_en
- drv2605.fire_haptic:
id: haptic
waveform: 27
on_error:
then:
- drv2605.fire_haptic:
id: haptic
waveform: 56
on_end:
then:
- output.turn_off: amp_en
- drv2605.fire_haptic:
id: haptic
waveform: 44
speaker:
- platform: i2s_audio
dac_type: external
i2s_dout_pin: GPIO3
mode: mono
id: amp_id
i2s_audio_id: i2s_amp
#media_player:
# - platform: i2s_audio
# name: ESPHome I2S Media Player
# dac_type: external
# i2s_dout_pin: GPIO3
# i2s_audio_id: i2s_amp
# mode: mono
# on_play:
# output.turn_on: amp_en
# on_pause:
# output.turn_off: amp_en
# on_idle:
# output.turn_off: amp_en
number:
- platform: template
name: waveform of choice press
id: wv_o_c
min_value: 1
max_value: 255
step: 1
optimistic: true
- platform: template
name: waveform of choice release
id: wv_o_c2
min_value: 1
max_value: 255
step: 1
optimistic: true
output:
- platform: gpio
pin: GPIO32
id: ntc_vcc
- platform: gpio
pin:
number: GPIO4
mode: OUTPUT_OPEN_DRAIN
id: amp_en
light:
- platform: neopixelbus
type: GRB
variant: SK6812
pin: GPIO15
num_leds: 42
internal: true
id: led_pixels
color_correct: [40%, 40%, 40% ] # limit max brightness
- platform: partition
name: Light Divider
segments:
- id: led_pixels
from: 10
to: 14
effects:
- addressable_twinkle:
- addressable_flicker:
- addressable_fireworks:
- platform: partition
name: Environment Divider
segments:
- id: led_pixels
from: 23
to: 31
effects:
- addressable_twinkle:
- addressable_flicker:
- addressable_fireworks:
- platform: partition
name: Vertical Line
segments:
- id: led_pixels
from: 0
to: 9
- id: led_pixels
from: 15
to: 22
- id: led_pixels
from: 32
to: 41
effects:
- addressable_twinkle:
- addressable_flicker:
- addressable_fireworks:
mpr121:
id: mpr121_
address: 0x5C
touch_debounce: 1
release_debounce: 1
touch_threshold: 10
release_threshold: 7
button:
- platform: restart
name: Restart device
id: restart_internal
entity_category: config
- platform: safe_mode
name: Safe Mode Boot
entity_category: diagnostic
- platform: template
name: Reset DRV2605L
entity_category: diagnostic
on_press:
then:
- drv2605.reset:
id: haptic
- platform: template
name: Calibrate DRV2605L
entity_category: diagnostic
on_press:
then:
- drv2605.calibrate:
id: haptic
binary_sensor:
- platform: gpio
name: physical button
pin:
number: GPIO34
inverted: true
# on_press:
# then:
# - voice_assistant.start:
# on_release:
# then:
# - voice_assistant.stop:
- platform: gpio
name: LED Power Fault
pin: GPIO36
- platform: mpr121
id: button_bottom_left
channel: 0
name: Light down
on_press:
then:
- drv2605.fire_haptic:
id: haptic
waveform: !lambda return id(wv_o_c).state;
on_release:
then:
- drv2605.fire_haptic:
id: haptic
waveform: !lambda return id(wv_o_c2).state;
- platform: mpr121
id: button_top_left
channel: 1
name: Light up
on_press:
then:
- drv2605.fire_haptic:
id: haptic
waveform: 4
- platform: mpr121
id: button_bottom_right
channel: 2
name: Environment down
on_press:
then:
- drv2605.fire_haptic:
id: haptic
waveform: 7
- platform: mpr121
id: button_top_right
channel: 3
name: Environment up
on_press:
then:
- voice_assistant.start:
on_release:
then:
- voice_assistant.stop:
# - drv2605.fire_haptic:
# id: haptic
# waveform: 54
- platform: mpr121
id: button_proximity
channel: 12
name: Proximity
# touch_threshold: 5
# release_threshold: 5
- platform: status
name: "${device_name} Status"
bme680_bsec:
sensor:
- platform: bme680_bsec
temperature:
name: "BME680 Temperature"
pressure:
name: "BME680 Pressure"
humidity:
name: "BME680 Humidity"
iaq:
name: "BME680 IAQ"
id: iaq
co2_equivalent:
name: "BME680 CO2 Equivalent"
breath_voc_equivalent:
name: "BME680 Breath VOC Equivalent"
- platform: bh1750
name: "BH1750 Illuminance"
address: 0x23
update_interval: 60s
- platform: ntc
name: "Board temperature"
sensor: board_temp_resistance
entity_category: diagnostic
calibration:
b_constant: 3435
reference_temperature: 25C
reference_resistance: 10kOhm
- platform: resistance
id: board_temp_resistance
sensor: board_temp_source
configuration: UPSTREAM
resistor: 10kOhm
- platform: adc
pin: GPIO33
id: board_temp_source
update_interval: never
attenuation: 11db
internal: true
interval:
- interval: 30s
then:
- output.turn_on: ntc_vcc
- component.update: board_temp_source
- output.turn_off: ntc_vcc
text_sensor:
- platform: bme680_bsec
iaq_accuracy:
name: "BME680 IAQ Accuracy"
- platform: template
name: "BME680 IAQ Classification"
icon: "mdi:checkbox-marked-circle-outline"
lambda: |-
if ( int(id(iaq).state) <= 50) {
return {"Excellent"};
}
else if (int(id(iaq).state) >= 51 && int(id(iaq).state) <= 100) {
return {"Good"};
}
else if (int(id(iaq).state) >= 101 && int(id(iaq).state) <= 150) {
return {"Lightly polluted"};
}
else if (int(id(iaq).state) >= 151 && int(id(iaq).state) <= 200) {
return {"Moderately polluted"};
}
else if (int(id(iaq).state) >= 201 && int(id(iaq).state) <= 250) {
return {"Heavily polluted"};
}
else if (int(id(iaq).state) >= 251 && int(id(iaq).state) <= 350) {
return {"Severely polluted"};
}
else if (int(id(iaq).state) >= 351) {
return {"Extremely polluted"};
}
else {
return {"error"};
}