-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathesp32korvo_esphome.yaml
342 lines (317 loc) · 7.28 KB
/
esp32korvo_esphome.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
substitutions:
esphome:
name: ${device_name}
min_version: 2023.11.0
platformio_options:
board_build.flash_mode: dio
on_boot:
- priority: -100
then:
- wait_until: api.connected
- delay: 1s
- if:
condition:
switch.is_on: use_wake_word
then:
- voice_assistant.start_continuous:
esp32:
board: esp-wrover-kit
framework:
type: arduino
version: recommended
external_components:
- source: github://rpatel3001/esphome@es8311
components: [ es8311 ]
- source: github://rpatel3001/esphome@es7210
components: [ es7210 ]
- source: github://pr#5230
components:
- esp_adf
# Enable logging
logger:
##### API KEY #####
api:
encryption:
key: ${apikey}
##### OTA PASSWORD #####
ota:
password: ${wifi_password}
safe_mode: true
reboot_timeout: 3min
num_attempts: 3
text_sensor:
- platform: wifi_info
ip_address:
name: "${device_name} IP Address"
time:
platform: homeassistant
id: homeassistant_time
#### WIFI PASSWORD ###
wifi:
networks:
- id: wifi_default
ssid: ${wifi_ssid}
password: ${wifi_password}
ap:
ssid: ${device_name}
password: ${wifi_password}
i2c:
sda: GPIO19
scl: GPIO32
scan: true
frequency: 400kHz
es8311:
address: 0x18
es7210:
address: 0x40
output:
- platform: gpio
id: pa_ctrl
pin: GPIO12
i2s_audio:
- id: codec
i2s_lrclk_pin: GPIO22
i2s_bclk_pin: GPIO25
i2s_mclk_pin:
number: GPIO0
allow_other_uses: true
ignore_strapping_warning: true
- id: mic_adc
i2s_lrclk_pin: GPIO26
i2s_bclk_pin: GPIO27
i2s_mclk_pin:
number: GPIO0
allow_other_uses: true
ignore_strapping_warning: true
speaker:
- platform: i2s_audio
id: external_speaker
dac_type: external
i2s_audio_id: codec
i2s_dout_pin: GPIO13
mode: mono
microphone:
- platform: i2s_audio
id: external_mic
adc_type: external
i2s_audio_id: mic_adc
i2s_din_pin: GPIO36
pdm: false
voice_assistant:
id: voice_asst
microphone: external_mic
speaker: external_speaker
noise_suppression_level: 2
auto_gain: 15dBFS
volume_multiplier: 0.5
use_wake_word: false
on_listening:
- light.turn_on:
id: led_ring
blue: 100%
red: 0%
green: 0%
brightness: 100%
effect: wakeword
on_tts_start:
- light.turn_on:
id: led_ring
blue: 0%
red: 0%
green: 100%
brightness: 50%
effect: pulse
on_end:
- delay: 100ms
- wait_until:
not:
speaker.is_playing:
- script.execute: reset_led
on_error:
- light.turn_on:
id: led_ring
blue: 0%
red: 100%
green: 0%
brightness: 100%
effect: none
- delay: 1s
- script.execute: reset_led
- script.wait: reset_led
- lambda: |-
if (code == "wake-provider-missing" || code == "wake-engine-missing") {
id(use_wake_word).turn_off();
}
script:
- id: reset_led
then:
- if:
condition:
switch.is_on: use_wake_word
then:
- light.turn_on:
id: led_ring
blue: 30%
red: 0%
green: 0%
brightness: 25%
effect: none
else:
- light.turn_off: led_ring
switch:
- platform: template
name: Use wake word
id: use_wake_word
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
entity_category: config
on_turn_on:
- lambda: id(voice_asst).set_use_wake_word(true);
- if:
condition:
not:
- voice_assistant.is_running
then:
- voice_assistant.start_continuous
- script.execute: reset_led
on_turn_off:
- voice_assistant.stop
- script.execute: reset_led
# Restart option
- platform: restart
name: "${device_name} Restart"
light:
- platform: esp32_rmt_led_strip
id: led_ring
name: "${device_name} Light"
pin: GPIO33
num_leds: 12
rmt_channel: 0
rgb_order: GRB
chipset: ws2812
default_transition_length: 0s
effects:
- pulse:
name: "Pulse"
transition_length: 0.5s
update_interval: 0.5s
- addressable_twinkle:
name: "Working"
twinkle_probability: 5%
progress_interval: 4ms
- addressable_color_wipe:
name: "Wakeword"
colors:
- red: 28%
green: 100%
blue: 90%
num_leds: 12
add_led_interval: 40ms
reverse: false
binary_sensor:
- platform: template
name: "${device_name} Volume Up"
id: btn_volume_up
- platform: template
name: "${device_name} Volume Down"
id: btn_volume_down
- platform: template
name: "${device_name} Set"
id: btn_set
- platform: template
name: "${device_name} Play"
id: btn_play
- platform: template
name: "${device_name} Mode"
id: btn_mode
- platform: template
name: "${device_name} Record"
id: btn_record
on_press:
- output.turn_on: pa_ctrl
- voice_assistant.start:
- light.turn_on:
id: led_ring
brightness: 100%
effect: "Wakeword"
on_release:
- voice_assistant.stop:
- output.turn_off: pa_ctrl
- light.turn_off:
id: led_ring
# Status de connection
- platform: status
name: "${device_name} Status"
sensor:
- id: button_adc
platform: adc
internal: true
pin: 39
attenuation: 11db
update_interval: 15ms
filters:
- median:
window_size: 5
send_every: 5
send_first_at: 1
- delta: 0.1
on_value_range:
- below: 0.55
then:
- binary_sensor.template.publish:
id: btn_volume_up
state: ON
- above: 0.65
below: 0.92
then:
- binary_sensor.template.publish:
id: btn_volume_down
state: ON
- above: 1.02
below: 1.33
then:
- binary_sensor.template.publish:
id: btn_set
state: ON
- above: 1.43
below: 1.77
then:
- binary_sensor.template.publish:
id: btn_play
state: ON
- above: 1.87
below: 2.15
then:
- binary_sensor.template.publish:
id: btn_mode
state: ON
- above: 2.25
below: 2.56
then:
- binary_sensor.template.publish:
id: btn_record
state: ON
- above: 2.8
then:
- binary_sensor.template.publish:
id: btn_volume_up
state: OFF
- binary_sensor.template.publish:
id: btn_volume_down
state: OFF
- binary_sensor.template.publish:
id: btn_set
state: OFF
- binary_sensor.template.publish:
id: btn_play
state: OFF
- binary_sensor.template.publish:
id: btn_mode
state: OFF
- binary_sensor.template.publish:
id: btn_record
state: OFF
# Wifi signal
- platform: wifi_signal
name: "${device_name} WiFi Signal"
update_interval: 60s