-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathesp32-audio-kit.yaml
259 lines (222 loc) · 4.72 KB
/
esp32-audio-kit.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
esphome:
name: esp32-audio-kit
substitutions:
NODE: DIY Media
NAME: mediasatalpha
esp32:
board: esp-wrover-kit
framework:
type: arduino
external_components:
- source:
type: git
url: https://github.com/jaredquinn/esphome-wx
components: [es8388]
<<: !include includes/common_network.yaml
packages:
internal: !include packages/internal_sensors.yaml
debug: !include packages/debug_esp32.yaml
logger:
level: DEBUG
# PSRam required for any kind of reasonable playback!
psram:
# See the es8388 component in this repository
es8388:
i2c:
sda: GPIO33
scl: GPIO32
frequency: 400kHz
scan: true
# We aren't currently using the SPI bus but here is
# the config
#
#spi:
# mosi_pin: GPIO15
# miso_pin: GPIO2
# clk_pin: GPIO14
i2s_audio:
i2s_lrclk_pin: GPIO25
i2s_bclk_pin: GPIO27
i2s_mclk_pin: GPIO0
microphone:
- platform: i2s_audio
id: i2smic
i2s_din_pin: GPIO35
adc_type: external
pdm: false
media_player:
- platform: i2s_audio
name: DIY Media 1
i2s_dout_pin: GPIO26
dac_type: external
mode: mono
id: i2smedia
on_play:
- logger.log: "Playback started!"
on_pause:
- logger.log: "Playback paused!"
on_idle:
- logger.log: "Playback finished!"
voice_assistant:
microphone: i2smic
media_player: i2smedia
on_listening:
- light.turn_on:
id: red_led
on_start:
- light.turn_off:
id: red_led
on_stt_end:
- light.turn_off:
id: red_led
- text_sensor.template.publish:
id: last_stt
state: !lambda 'return x;'
on_stt_vad_start:
- light.turn_off:
id: red_led
- homeassistant.service:
service: input_text.set_value
data:
value: media_player.voice_box_player
entity_id: input_text.last_voice_box_triggered
on_tts_start:
- light.turn_off:
id: red_led
- text_sensor.template.publish:
id: last_tts
state: !lambda 'return x;'
- homeassistant.service:
service: script.esphome_notify
data:
target: media_player.voice_box_player
data_template:
message: "{{ msg }}"
variables:
msg: return x;
output:
- platform: ledc
pin:
number: GPIO22
inverted: true
id: output_led
# Using this as an LED causes button issues
#
# - platform: ledc
# pin:
# number: GPIO19
# allow_other_uses: true
# inverted: true
# mode: input_pullup
# id: light19
light:
- platform: binary
name: "Red LED"
id: red_led
output: output_led
restore_mode: ALWAYS_OFF
# Using this as an LED causes button issues
#
# - platform: binary
# name: "Shared LED"
# output: light19
# restore_mode: ALWAYS_OFF
switch:
- platform: gpio
pin: GPIO21
name: "Amplifier"
sensor:
- platform: es8388
output_volume:
name: "Output Volume"
input_gain:
name: "Input Gain"
binary_sensor:
- platform: gpio
pin:
number: GPIO39
inverted: true
name: "Jack Sense"
filters:
- delayed_off: 50ms
- delayed_on: 50ms
- platform: gpio
pin:
number: GPIO34
inverted: true
name: "SDCard Sense"
filters:
- delayed_off: 50ms
- delayed_on: 50ms
- platform: gpio
pin:
number: GPIO36
inverted: true
name: "Key 1"
filters:
- delayed_off: 10ms
on_click:
- if:
condition: voice_assistant.is_running
then:
- voice_assistant.stop:
- light.turn_off:
id: red_led
else:
- voice_assistant.start_continuous:
- platform: gpio
pin:
number: GPIO13
inverted: true
name: "Key 2"
filters:
- delayed_off: 10ms
- platform: gpio
pin:
number: GPIO19
inverted: true
mode: input_pullup
#allow_other_uses: true
name: "Key 3"
filters:
- delayed_off: 10ms
- platform: gpio
pin:
number: GPIO23
mode: input_pullup
inverted: true
name: "Key 4"
filters:
- delayed_off: 10ms
- platform: gpio
pin:
number: GPIO18
mode: input_pullup
inverted: true
name: "Key 5"
filters:
- delayed_off: 10ms
- platform: gpio
pin:
number: GPIO5
mode: input_pullup
inverted: true
name: "Key 6"
filters:
- delayed_off: 10ms
on_press:
- voice_assistant.start:
silence_detection: false
on_release:
- voice_assistant.stop:
text_sensor:
- platform: template
name: "Last STT"
id: last_stt
entity_category: diagnostic
update_interval: never
- platform: template
name: "Last TTS"
id: last_tts
entity_category: diagnostic
update_interval: never