Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HarvsG/40468d1d0e3f444d9a1907f26a503bc6 to your computer and use it in GitHub Desktop.
Save HarvsG/40468d1d0e3f444d9a1907f26a503bc6 to your computer and use it in GitHub Desktop.
ESPHome configs for M5Stack Atom Echo.
# This config enables micro wake word 2 the 'use micro wake word' toggles between it and streaming audio to HA for wake word detection
# Replies come through the terrible on-device speaker
substitutions:
name: m5stack-atom-echo
friendly_name: M5Stack Atom Echo
esphome:
name: ${name}
name_add_mac_suffix: true
friendly_name: ${friendly_name}
min_version: 2024.7.1
project:
name: m5stack.atom-echo-voice-assistant
version: "24.7.4.1"
esp32:
board: m5stack-atom
framework:
type: esp-idf
logger:
api:
encryption:
key: +someapikey=
ota:
- platform: esphome
id: ota_esphome
dashboard_import:
package_import_url: github://esphome/firmware/voice-assistant/m5stack-atom-echo.yaml@main
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
button:
- platform: factory_reset
id: factory_reset_btn
name: Factory reset
i2s_audio:
- id: i2s_audio_bus
i2s_lrclk_pin: GPIO33
i2s_bclk_pin: GPIO19
microphone:
- platform: i2s_audio
id: echo_microphone
i2s_din_pin: GPIO23
adc_type: external
pdm: true
speaker:
- platform: i2s_audio
id: echo_speaker
i2s_dout_pin: GPIO22
dac_type: external
mode: mono
voice_assistant:
id: va
microphone: echo_microphone
speaker: echo_speaker
noise_suppression_level: 2
auto_gain: 31dBFS
volume_multiplier: 2.0
vad_threshold: 3
on_listening:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
effect: "Slow Pulse"
on_stt_vad_end:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
effect: "Fast Pulse"
on_tts_start:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
brightness: 100%
effect: none
on_end:
- delay: 100ms
- voice_assistant.stop:
- wait_until:
not:
voice_assistant.is_running:
- wait_until:
not:
switch.is_on: timer_ringing
- if:
condition:
switch.is_on: use_micro_wake_word
then:
- micro_wake_word.start:
- script.execute: reset_led
else:
- voice_assistant.start_continuous:
- script.execute: reset_led
on_error:
- light.turn_on:
id: led
red: 100%
green: 0%
blue: 0%
brightness: 100%
effect: none
- delay: 2s
- script.execute: reset_led
on_client_connected:
- delay: 5s
- if:
condition:
switch.is_on: use_micro_wake_word
then:
- micro_wake_word.start:
else:
- voice_assistant.start_continuous:
- script.execute: reset_led
on_client_disconnected:
- voice_assistant.stop:
- micro_wake_word.stop:
on_timer_finished:
- voice_assistant.stop:
- micro_wake_word.stop:
- switch.turn_on: timer_ringing
- wait_until:
not:
microphone.is_capturing:
- light.turn_on:
id: led
red: 0%
green: 100%
blue: 0%
brightness: 100%
effect: "Fast Pulse"
- while:
condition:
switch.is_on: timer_ringing
then:
- lambda: id(echo_speaker).play(id(timer_finished_wave_file), sizeof(id(timer_finished_wave_file)));
- delay: 1s
- wait_until:
not:
speaker.is_playing:
- light.turn_off: led
- switch.turn_off: timer_ringing
- if:
condition:
switch.is_on: use_micro_wake_word
then:
- micro_wake_word.start:
- script.execute: reset_led
else:
- voice_assistant.start_continuous:
- script.execute: reset_led
binary_sensor:
# butto does the following:
# short click - stop a timer, if no timer then restart either microwakeword or voice assistant continuous
- platform: gpio
pin:
number: GPIO39
inverted: true
name: Button
disabled_by_default: true
entity_category: diagnostic
id: echo_button
on_multi_click:
- timing:
- ON for at least 50ms
- OFF for at least 50ms
then:
- if:
condition:
switch.is_on: timer_ringing
then:
- switch.turn_off: timer_ringing
else:
- if:
condition:
switch.is_on: use_micro_wake_word
then:
- voice_assistant.stop
- micro_wake_word.stop:
- delay: 1s
- script.execute: reset_led
- script.wait: reset_led
- micro_wake_word.start:
else:
- if:
condition: voice_assistant.is_running
then:
- voice_assistant.stop:
- script.execute: reset_led
- voice_assistant.start_continuous:
- timing:
- ON for at least 10s
then:
- button.press: factory_reset_btn
light:
- platform: esp32_rmt_led_strip
id: led
name: None
disabled_by_default: true
entity_category: config
pin: GPIO27
default_transition_length: 0s
chipset: SK6812
num_leds: 1
rgb_order: grb
rmt_channel: 0
effects:
- pulse:
name: "Slow Pulse"
transition_length: 250ms
update_interval: 250ms
min_brightness: 50%
max_brightness: 100%
- pulse:
name: "Fast Pulse"
transition_length: 100ms
update_interval: 100ms
min_brightness: 50%
max_brightness: 100%
script:
- id: reset_led
then:
- if:
condition:
- switch.is_on: use_micro_wake_word
- switch.is_on: use_listen_light
then:
- light.turn_on:
id: led
red: 100%
green: 89%
blue: 71%
brightness: 60%
effect: none
else:
- if:
condition:
- switch.is_off: use_micro_wake_word
- switch.is_on: use_listen_light
then:
- light.turn_on:
id: led
red: 0%
green: 100%
blue: 100%
brightness: 60%
effect: none
else:
- light.turn_off: led
switch:
- platform: template
name: Use micro wake word
id: use_micro_wake_word
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
entity_category: config
on_turn_on:
- voice_assistant.stop:
- lambda: id(va).set_use_wake_word(false);
- delay: 1s
- micro_wake_word.start:
- script.execute: reset_led
on_turn_off:
- micro_wake_word.stop:
- lambda: id(va).set_use_wake_word(true);
- delay: 1s
- voice_assistant.start_continuous:
- script.execute: reset_led
- platform: template
name: Use listen light
id: use_listen_light
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
entity_category: config
on_turn_on:
- script.execute: reset_led
on_turn_off:
- script.execute: reset_led
- platform: template
id: timer_ringing
optimistic: true
internal: true
restore_mode: ALWAYS_OFF
on_turn_on:
- delay: 15min
- switch.turn_off: timer_ringing
external_components:
- source: github://pr#5230
components:
- esp_adf
refresh: 0s
- source: github://jesserockz/esphome-components
components: [file]
refresh: 0s
- source:
type: git
url: https://github.com/kahrendt/esphome
ref: mww-v2-external-library
refresh: 0s
components: [ micro_wake_word ]
esp_adf:
file:
- id: timer_finished_wave_file
file: https://github.com/esphome/firmware/raw/main/voice-assistant/sounds/timer_finished.wav
micro_wake_word:
on_wake_word_detected:
- voice_assistant.start:
wake_word: !lambda return wake_word;
vad:
model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/vad.json
models:
- model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/okay_nabu.json
# - model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/hey_jarvis.json
# - model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/hey_mycroft.json
# This config enables micro wake word 2 the 'use micro wake word' toggles between it and streaming audio to HA for wake word detection
# Replies come through `media_player.xxxxxx` where xxxxxx is the media_player name set in the text input in the config box of the device
# in the HA UI, see https://community.home-assistant.io/t/how-to-access-device-area-as-a-variable-within-esphome-config/748195/17
substitutions:
name: m5stack-atom-echo
friendly_name: M5Stack Atom Echo
esphome:
name: ${name}
name_add_mac_suffix: true
friendly_name: ${friendly_name}
min_version: 2024.7.1
project:
name: m5stack.atom-echo-voice-assistant
version: "24.7.4.1"
esp32:
board: m5stack-atom
framework:
type: esp-idf
logger:
api:
encryption:
key: +someapikey=
ota:
- platform: esphome
id: ota_esphome
dashboard_import:
package_import_url: github://esphome/firmware/voice-assistant/m5stack-atom-echo.yaml@main
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
button:
- platform: factory_reset
id: factory_reset_btn
name: Factory reset
i2s_audio:
- id: i2s_audio_bus
i2s_lrclk_pin: GPIO33
i2s_bclk_pin: GPIO19
microphone:
- platform: i2s_audio
id: echo_microphone
i2s_din_pin: GPIO23
adc_type: external
pdm: true
text:
- platform: template
name: Media Player
id: media_player
mode: text
optimistic: true
restore_value: true # Save value every 60 seconds
entity_category: config
icon: mdi:cast
#speaker:
# - platform: i2s_audio
# id: echo_speaker
# i2s_dout_pin: GPIO21 # <- speaker is on 22 so this disables the speaker
# dac_type: external
# mode: mono
voice_assistant:
id: va
microphone: echo_microphone
# speaker: echo_speaker
noise_suppression_level: 2
auto_gain: 31dBFS
volume_multiplier: 2.0
vad_threshold: 3
on_listening:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
effect: "Slow Pulse"
on_stt_vad_end:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
effect: "Fast Pulse"
on_tts_start:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
brightness: 100%
effect: none
on_end:
- delay: 100ms
- voice_assistant.stop:
- wait_until:
not:
voice_assistant.is_running:
- wait_until:
not:
switch.is_on: timer_ringing
- if:
condition:
switch.is_on: use_micro_wake_word
then:
- micro_wake_word.start:
- script.execute: reset_led
else:
- voice_assistant.start_continuous:
- script.execute: reset_led
on_error:
- light.turn_on:
id: led
red: 100%
green: 0%
blue: 0%
brightness: 100%
effect: none
- delay: 2s
- script.execute: reset_led
on_client_connected:
- delay: 5s
- if:
condition:
switch.is_on: use_micro_wake_word
then:
- micro_wake_word.start:
else:
- voice_assistant.start_continuous:
- script.execute: reset_led
on_client_disconnected:
- voice_assistant.stop:
- micro_wake_word.stop:
on_timer_finished:
- voice_assistant.stop:
- micro_wake_word.stop:
- switch.turn_on: timer_ringing
- wait_until:
not:
microphone.is_capturing:
- light.turn_on:
id: led
red: 0%
green: 100%
blue: 0%
brightness: 100%
effect: "Fast Pulse"
- while:
condition:
switch.is_on: timer_ringing
then:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: !lambda |-
return "media_player." + id(media_player).state;
media_content_id: https://github.com/esphome/firmware/raw/main/voice-assistant/sounds/timer_finished.wav
media_content_type: music
announce: "true"
- delay: 1s
- light.turn_off: led
- switch.turn_off: timer_ringing
- if:
condition:
switch.is_on: use_micro_wake_word
then:
- micro_wake_word.start:
- script.execute: reset_led
else:
- voice_assistant.start_continuous:
- script.execute: reset_led
on_tts_end:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: !lambda |-
return "media_player." + id(media_player).state;
media_content_id: !lambda 'return x;'
media_content_type: music
announce: "true"
binary_sensor:
# butto does the following:
# short click - stop a timer, if no timer then restart either microwakeword or voice assistant continuous
- platform: gpio
pin:
number: GPIO39
inverted: true
name: Button
disabled_by_default: true
entity_category: diagnostic
id: echo_button
on_multi_click:
- timing:
- ON for at least 50ms
- OFF for at least 50ms
then:
- if:
condition:
switch.is_on: timer_ringing
then:
- switch.turn_off: timer_ringing
else:
- if:
condition:
switch.is_on: use_micro_wake_word
then:
- voice_assistant.stop
- micro_wake_word.stop:
- delay: 1s
- script.execute: reset_led
- script.wait: reset_led
- micro_wake_word.start:
else:
- if:
condition: voice_assistant.is_running
then:
- voice_assistant.stop:
- script.execute: reset_led
- voice_assistant.start_continuous:
- timing:
- ON for at least 10s
then:
- button.press: factory_reset_btn
light:
- platform: esp32_rmt_led_strip
id: led
name: None
disabled_by_default: true
entity_category: config
pin: GPIO27
default_transition_length: 0s
chipset: SK6812
num_leds: 1
rgb_order: grb
rmt_channel: 0
effects:
- pulse:
name: "Slow Pulse"
transition_length: 250ms
update_interval: 250ms
min_brightness: 50%
max_brightness: 100%
- pulse:
name: "Fast Pulse"
transition_length: 100ms
update_interval: 100ms
min_brightness: 50%
max_brightness: 100%
script:
- id: reset_led
then:
- if:
condition:
- switch.is_on: use_micro_wake_word
- switch.is_on: use_listen_light
then:
- light.turn_on:
id: led
red: 100%
green: 89%
blue: 71%
brightness: 60%
effect: none
else:
- if:
condition:
- switch.is_off: use_micro_wake_word
- switch.is_on: use_listen_light
then:
- light.turn_on:
id: led
red: 0%
green: 100%
blue: 100%
brightness: 60%
effect: none
else:
- light.turn_off: led
switch:
- platform: template
name: Use micro wake word
id: use_micro_wake_word
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
entity_category: config
on_turn_on:
- voice_assistant.stop:
- lambda: id(va).set_use_wake_word(false);
- delay: 1s
- micro_wake_word.start:
- script.execute: reset_led
on_turn_off:
- micro_wake_word.stop:
- lambda: id(va).set_use_wake_word(true);
- delay: 1s
- voice_assistant.start_continuous:
- script.execute: reset_led
- platform: template
name: Use listen light
id: use_listen_light
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
entity_category: config
on_turn_on:
- script.execute: reset_led
on_turn_off:
- script.execute: reset_led
- platform: template
id: timer_ringing
optimistic: true
internal: true
restore_mode: ALWAYS_OFF
on_turn_on:
- delay: 15min
- switch.turn_off: timer_ringing
external_components:
- source: github://pr#5230
components:
- esp_adf
refresh: 0s
- source: github://jesserockz/esphome-components
components: [file]
refresh: 0s
- source:
type: git
url: https://github.com/kahrendt/esphome
ref: mww-v2-external-library
refresh: 0s
components: [ micro_wake_word ]
esp_adf:
#file:
# - id: timer_finished_wave_file
# file: https://github.com/esphome/firmware/raw/main/voice-assistant/sounds/timer_finished.wav
micro_wake_word:
on_wake_word_detected:
- voice_assistant.start:
wake_word: !lambda return wake_word;
vad:
model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/vad.json
models:
- model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/okay_nabu.json
# - model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/hey_jarvis.json
# - model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/hey_mycroft.json
# This config uses micro wake word 2 optionally
# It also allows the user to choose a media_player to play replies on
substitutions:
name: m5stack-atom-echo
friendly_name: M5Stack Atom Echo
micro_wake_word_model: hey_jarvis # hey_jarvis and hey_mycroft are also supported
esphome:
name: ${name}
name_add_mac_suffix: true
friendly_name: ${friendly_name}
min_version: 2024.7.1
project:
name: m5stack.atom-echo-wake-word-voice-assistant
version: "24.7.4.1"
on_boot:
priority: 600
then:
- if:
condition:
lambda: return id(reply_location).state == "On device";
then:
- logger.log: "setting speaker to echo_speaker in on_boot"
- lambda: id(va).set_speaker(echo_speaker);
else:
- logger.log: "Using another media player so speaker not set"
esp32:
board: m5stack-atom
framework:
type: esp-idf
logger:
api:
encryption:
key: !secret m5_stack_api_key
ota:
- platform: esphome
id: ota_esphome
- platform: http_request
id: ota_http_request
update:
- platform: http_request
id: update_http_request
name: Firmware
source: https://firmware.esphome.io/wake-word-voice-assistant/m5stack-atom-echo/manifest.json
http_request:
dashboard_import:
package_import_url: github://esphome/firmware/wake-word-voice-assistant/m5stack-atom-echo.yaml@main
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
improv_serial:
button:
- platform: factory_reset
id: factory_reset_btn
name: Factory reset
- platform: restart
id: restart_btn
internal: true
i2s_audio:
- id: i2s_audio_bus
i2s_lrclk_pin: GPIO33
i2s_bclk_pin: GPIO19
microphone:
- platform: i2s_audio
id: echo_microphone
i2s_din_pin: GPIO23
adc_type: external
pdm: true
speaker:
- platform: i2s_audio
id: echo_speaker
i2s_dout_pin: GPIO22
dac_type: external
mode: mono
voice_assistant:
id: va
microphone: echo_microphone
noise_suppression_level: 2
auto_gain: 31dBFS
volume_multiplier: 2.0
vad_threshold: 3
on_listening:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
effect: "Slow Pulse"
on_stt_vad_end:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
effect: "Fast Pulse"
on_tts_start:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
brightness: 100%
effect: none
on_end:
- delay: 100ms
- voice_assistant.stop:
- wait_until:
not:
voice_assistant.is_running:
- wait_until:
not:
switch.is_on: timer_ringing
- if:
condition:
lambda: return id(wake_word_engine_location).state == "On device";
then:
- micro_wake_word.start:
- script.execute: reset_led
else:
- voice_assistant.start_continuous:
- script.execute: reset_led
on_error:
- light.turn_on:
id: led
red: 100%
green: 0%
blue: 0%
brightness: 100%
effect: none
- delay: 2s
- script.execute: reset_led
on_client_connected:
- delay: 5s
- if:
condition:
lambda: return id(wake_word_engine_location).state == "On device";
then:
- micro_wake_word.start:
else:
- voice_assistant.start_continuous:
- script.execute: reset_led
on_client_disconnected:
- voice_assistant.stop:
- micro_wake_word.stop:
## external media play support, on_timer_finished overwritten
on_timer_finished:
- voice_assistant.stop:
- micro_wake_word.stop:
- switch.turn_on: timer_ringing
- wait_until:
not:
microphone.is_capturing:
- light.turn_on:
id: led
red: 0%
green: 100%
blue: 0%
brightness: 100%
effect: "Fast Pulse"
- while:
condition:
switch.is_on: timer_ringing
then:
- if:
condition:
lambda: return id(reply_location).state == "Another Media Player";
then:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: !lambda |-
return id(media_player).state;
media_content_id: https://github.com/esphome/firmware/raw/main/voice-assistant/sounds/timer_finished.wav
media_content_type: music
announce: "true"
else:
- lambda: id(echo_speaker).play(id(timer_finished_wave_file), sizeof(id(timer_finished_wave_file)));
- delay: 1s
- wait_until:
not:
speaker.is_playing:
- light.turn_off: led
- switch.turn_off: timer_ringing
- if:
condition:
lambda: return id(wake_word_engine_location).state == "On device";
then:
- micro_wake_word.start:
- script.execute: reset_led
else:
- voice_assistant.start_continuous:
- script.execute: reset_led
on_tts_end:
- if:
condition:
lambda: return id(reply_location).state == "Another Media Player";
then:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: !lambda |-
return id(media_player).state;
media_content_id: !lambda 'return x;'
media_content_type: music
announce: "true"
binary_sensor:
# button does the following:
# short click - stop a timer
# if no timer then restart either microwakeword or voice assistant continuous
- platform: gpio
pin:
number: GPIO39
inverted: true
name: Button
disabled_by_default: true
entity_category: diagnostic
id: echo_button
on_multi_click:
- timing:
- ON for at least 50ms
- OFF for at least 50ms
then:
- if:
condition:
switch.is_on: timer_ringing
then:
- switch.turn_off: timer_ringing
else:
- if:
condition:
lambda: return id(wake_word_engine_location).state == "On device";
then:
- voice_assistant.stop
- micro_wake_word.stop:
- delay: 1s
- script.execute: reset_led
- script.wait: reset_led
- micro_wake_word.start:
else:
- if:
condition: voice_assistant.is_running
then:
- voice_assistant.stop:
- script.execute: reset_led
- voice_assistant.start_continuous:
- timing:
- ON for at least 10s
then:
- button.press: factory_reset_btn
light:
- platform: esp32_rmt_led_strip
id: led
name: None
disabled_by_default: true
entity_category: config
pin: GPIO27
default_transition_length: 0s
chipset: SK6812
num_leds: 1
rgb_order: grb
rmt_channel: 0
effects:
- pulse:
name: "Slow Pulse"
transition_length: 250ms
update_interval: 250ms
min_brightness: 50%
max_brightness: 100%
- pulse:
name: "Fast Pulse"
transition_length: 100ms
update_interval: 100ms
min_brightness: 50%
max_brightness: 100%
script:
- id: reset_led
then:
- if:
condition:
- lambda: return id(wake_word_engine_location).state == "On device";
- switch.is_on: use_listen_light
then:
- light.turn_on:
id: led
red: 100%
green: 89%
blue: 71%
brightness: 60%
effect: none
else:
- if:
condition:
- lambda: return id(wake_word_engine_location).state != "On device";
- switch.is_on: use_listen_light
then:
- light.turn_on:
id: led
red: 0%
green: 100%
blue: 100%
brightness: 60%
effect: none
else:
- light.turn_off: led
switch:
- platform: template
name: Use listen light
id: use_listen_light
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
entity_category: config
on_turn_on:
- script.execute: reset_led
on_turn_off:
- script.execute: reset_led
- platform: template
id: timer_ringing
optimistic: true
internal: true
restore_mode: ALWAYS_OFF
on_turn_on:
- delay: 15min
- switch.turn_off: timer_ringing
select:
- platform: template
entity_category: config
name: Wake word engine location
id: wake_word_engine_location
optimistic: true
restore_value: true
options:
- In Home Assistant
- On device
initial_option: On device
on_value:
- if:
condition:
lambda: return x == "In Home Assistant";
then:
- micro_wake_word.stop
- delay: 500ms
- lambda: id(va).set_use_wake_word(true);
- voice_assistant.start_continuous:
- if:
condition:
lambda: return x == "On device";
then:
- lambda: id(va).set_use_wake_word(false);
- voice_assistant.stop
- delay: 500ms
- micro_wake_word.start
- platform: template
entity_category: config
name: Reply Location
id: reply_location
optimistic: true
restore_value: true
options:
- Another Media Player
- On device
initial_option: On device
set_action:
- logger.log: "set_action called for reply_location"
- logger.log: "new value set for reply_location, restarting to clear speaker settings"
- light.turn_on:
id: led
red: 100%
green: 100%
blue: 0%
brightness: 100%
effect: "Fast Pulse"
# restarting should be the device back into a state where va.speaker: is not set
- delay: 5s # give time to write settings
- button.press: restart_btn
text:
- platform: template
name: Media Player Entity ID
id: media_player
mode: text
optimistic: true
restore_value: true # Save value every 60 seconds
entity_category: config
icon: mdi:cast
external_components:
- source: github://pr#5230
components:
- esp_adf
refresh: 0s
- source: github://jesserockz/esphome-components
components: [file]
refresh: 0s
- source:
type: git
url: https://github.com/kahrendt/esphome
ref: mww-v2-external-library
refresh: 0s
components: [ micro_wake_word ]
esp_adf:
file:
- id: timer_finished_wave_file
file: https://github.com/esphome/firmware/raw/main/voice-assistant/sounds/timer_finished.wav
micro_wake_word:
on_wake_word_detected:
- voice_assistant.start:
wake_word: !lambda return wake_word;
vad:
models:
- model: ${micro_wake_word_model}
# This is essentially the default pre-micro wake word config but edited to reply on a media player
# edit lines 147 and 164 for your media player
esphome:
name: m5stack-atom-echo
friendly_name: M5Stack Atom Echo
min_version: 2024.6.0
name_add_mac_suffix: true
project:
name: m5stack.atom-echo-voice-assistant
version: "24.7.4.1"
esp32:
board: m5stack-atom
framework:
type: esp-idf
logger:
api:
encryption:
key: +someapikey=
ota:
- platform: esphome
id: ota_esphome
- platform: http_request
id: ota_http_request
update:
http_request:
dashboard_import:
package_import_url: github://esphome/firmware/voice-assistant/m5stack-atom-echo.yaml@main
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
on_connect:
- delay: 5s # Gives time for improv results to be transmitted
- ble.disable:
on_disconnect:
- ble.enable:
ap:
esp32_improv:
authorizer: none
button:
- platform: safe_mode
id: button_safe_mode
name: Safe Mode Boot
- platform: factory_reset
id: factory_reset_btn
name: Factory reset
i2s_audio:
- id: i2s_audio_bus
i2s_lrclk_pin: GPIO33
i2s_bclk_pin: GPIO19
microphone:
- platform: i2s_audio
id: echo_microphone
i2s_din_pin: GPIO23
adc_type: external
pdm: true
speaker:
- platform: i2s_audio
id: echo_speaker
i2s_dout_pin: GPIO21
dac_type: external
mode: mono
voice_assistant:
id: va
microphone: echo_microphone
speaker: echo_speaker
noise_suppression_level: 2
auto_gain: 31dBFS
volume_multiplier: 2.0
vad_threshold: 3
on_listening:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
effect: "Slow Pulse"
on_stt_vad_end:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
effect: "Fast Pulse"
on_tts_start:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
brightness: 100%
effect: none
on_end:
- delay: 100ms
- wait_until:
not:
switch.is_on: timer_ringing
- script.execute: reset_led
on_error:
- light.turn_on:
id: led
red: 100%
green: 0%
blue: 0%
brightness: 100%
effect: none
- delay: 1s
- script.execute: reset_led
on_client_connected:
- if:
condition:
switch.is_on: use_wake_word
then:
- voice_assistant.start_continuous:
- script.execute: reset_led
on_client_disconnected:
- if:
condition:
switch.is_on: use_wake_word
then:
- voice_assistant.stop:
- light.turn_off: led
on_timer_finished: # not currently working as it plays after the default version see https://community.home-assistant.io/t/how-to-override-an-action-in-a-package/748237 and https://github.com/esphome/issues/issues/6035
- switch.turn_on: timer_ringing
- light.turn_on:
id: led
red: 0%
green: 100%
blue: 0%
brightness: 100%
effect: "Fast Pulse"
- while:
condition:
switch.is_on: timer_ringing
then:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: media_player.study_speaker # <- this is hard-coded
media_content_id: https://github.com/esphome/firmware/raw/main/voice-assistant/sounds/timer_finished.wav
media_content_type: music
announce: "true"
- delay: 1s
- light.turn_off: led
- switch.turn_off: timer_ringing
- if:
condition:
switch.is_on: use_wake_word
then:
- voice_assistant.start_continuous:
- script.execute: reset_led
on_tts_end:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: media_player.study_speaker # <- this is hard-coded
media_content_id: !lambda 'return x;'
media_content_type: music
announce: "true"
use_wake_word: false
binary_sensor:
- platform: gpio
pin:
number: GPIO39
inverted: true
name: Button
disabled_by_default: true
entity_category: diagnostic
id: echo_button
on_multi_click:
- timing:
- ON for at least 50ms
- OFF for at least 50ms
then:
- if:
condition:
switch.is_on: timer_ringing
then:
- switch.turn_off: timer_ringing
else:
- if:
condition:
switch.is_off: use_wake_word
then:
- if:
condition: voice_assistant.is_running
then:
- voice_assistant.stop:
- script.execute: reset_led
else:
- voice_assistant.start:
else:
- voice_assistant.stop
- delay: 1s
- script.execute: reset_led
- script.wait: reset_led
- voice_assistant.start_continuous:
- timing:
- ON for at least 10s
then:
- button.press: factory_reset_btn
light:
- platform: esp32_rmt_led_strip
id: led
name: None
disabled_by_default: true
entity_category: config
pin: GPIO27
default_transition_length: 0s
chipset: SK6812
num_leds: 1
rgb_order: grb
rmt_channel: 0
effects:
- pulse:
name: "Slow Pulse"
transition_length: 250ms
update_interval: 250ms
min_brightness: 50%
max_brightness: 100%
- pulse:
name: "Fast Pulse"
transition_length: 100ms
update_interval: 100ms
min_brightness: 50%
max_brightness: 100%
script:
- id: reset_led
then:
- if:
condition:
- switch.is_on: use_wake_word
- switch.is_on: use_listen_light
then:
- light.turn_on:
id: led
red: 100%
green: 89%
blue: 71%
brightness: 60%
effect: none
else:
- light.turn_off: led
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(va).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
- lambda: id(va).set_use_wake_word(false);
- script.execute: reset_led
- platform: template
name: Use listen light
id: use_listen_light
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
entity_category: config
on_turn_on:
- script.execute: reset_led
on_turn_off:
- script.execute: reset_led
- platform: template
id: timer_ringing
optimistic: true
internal: true
restore_mode: ALWAYS_OFF
on_turn_on:
- delay: 15min
- switch.turn_off: timer_ringing
external_components:
- source: github://pr#5230
components:
- esp_adf
refresh: 0s
- source: github://jesserockz/esphome-components
components: [file]
refresh: 0s
esp_adf:
file:
- id: timer_finished_wave_file
file: https://github.com/esphome/firmware/raw/main/voice-assistant/sounds/timer_finished.wav
substitutions:
name: m5stack-atom-echo-b836b0
friendly_name: M5Stack Atom Echo b836b0
packages:
m5stack.atom-echo-voice-assistant: github://esphome/firmware/voice-assistant/m5stack-atom-echo.yaml@main
esphome:
name: ${name}
name_add_mac_suffix: false
friendly_name: ${friendly_name}
api:
encryption:
key: +someapikey=
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Until https://github.com/esphome/firmware/pull/233 is fixed/merged
update:
- platform: http_request
id: !remove update_http_request
# HarvsG's customisations
speaker: # <- from 2024.7.0 onwards see alternative below
- platform: i2s_audio
id: !extend echo_speaker
i2s_dout_pin: GPIO21 # <- It is actually on 22, so this disables the speaker
voice_assistant:
# speaker:remove! # <- this should work from esphome 2024.7.0 onwards
# volume_multiplier: 8.0 #<- this line is needed for 2024.7.0 but fixed in 2024.7.1
vad_threshold: 3
on_tts_end:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: media_player.study_speaker # <- this is hard-coded
media_content_id: !lambda 'return x;'
media_content_type: music
announce: "true"
# on_end: # not currently working as it plays after the default version see https://community.home-assistant.io/t/how-to-override-an-action-in-a-package/748237 and https://github.com/esphome/issues/issues/6035
# - delay: 100ms
# - wait_until:
# not:
# switch.is_on: timer_ringing
# - script.execute: reset_led
# on_timer_finished: # not currently working as it plays after the default version see https://community.home-assistant.io/t/how-to-override-an-action-in-a-package/748237 and https://github.com/esphome/issues/issues/6035
# - switch.turn_on: timer_ringing
# - light.turn_on:
# id: led
# red: 0%
# green: 100%
# blue: 0%
# brightness: 100%
# effect: "Fast Pulse"
# - while:
# condition:
# switch.is_on: timer_ringing
# then:
# - homeassistant.service:
# service: media_player.play_media
# data:
# entity_id: media_player.study_speaker # <- this is hard-coded
# media_content_id: https://github.com/esphome/firmware/raw/main/voice-assistant/sounds/timer_finished.wav
# media_content_type: music
# announce: "true"
# - delay: 1s
# - light.turn_off: led
# - switch.turn_off: timer_ringing
# - if:
# condition:
# switch.is_on: use_wake_word
# then:
# - voice_assistant.start_continuous:
# - script.execute: reset_led
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment