Created
February 20, 2025 07:54
-
-
Save michaelkleinhenz/5683118594033b85f700109b0620e051 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
substitutions: | |
name: m5stack-atom-echo | |
friendly_name: M5Stack Atom Echo | |
micro_wake_word_model: okay_nabu # alexa, hey_jarvis, hey_mycroft are also supported | |
esphome: | |
name: ${name} | |
name_add_mac_suffix: false | |
friendly_name: ${friendly_name} | |
min_version: 2024.9.0 | |
esp32: | |
board: m5stack-atom | |
framework: | |
type: esp-idf | |
version: 4.4.8 | |
platform_version: 5.4.0 | |
logger: | |
api: | |
encryption: | |
key: YOUR_API_KEY | |
ota: | |
- platform: esphome | |
id: ota_esphome | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
ap: | |
captive_portal: | |
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 | |
channel: 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: | |
- if: | |
condition: | |
switch.is_on: use_remote_media_player | |
then: | |
- logger.log: "using remote media player" | |
- speaker.volume_set: 10% | |
- homeassistant.service: | |
service: tts.cloud_say | |
data: | |
entity_id: !lambda 'return id(media_player_entity_id).state.c_str();' | |
message: !lambda 'return x;' | |
else: | |
- logger.log: "using internal speaker" | |
- speaker.volume_set: 100% | |
- 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: 2s # Give the api server time to settle | |
- 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: | |
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: | |
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 | |
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 | |
name: Use remote media player | |
id: use_remote_media_player | |
optimistic: true | |
restore_mode: RESTORE_DEFAULT_ON | |
entity_category: config | |
on_turn_on: | |
- logger.log: "use remote media player turned on" | |
- logger.log: | |
format: "current media player entity: %s" | |
args: ["id(media_player_entity_id).state.c_str()"] | |
on_turn_off: | |
- logger.log: "use remote media player turned off" | |
- logger.log: | |
format: "current media player entity: %s" | |
args: ["id(media_player_entity_id).state.c_str()"] | |
- platform: template | |
id: timer_ringing | |
optimistic: true | |
internal: true | |
restore_mode: ALWAYS_OFF | |
on_turn_on: | |
- delay: 15min | |
- switch.turn_off: timer_ringing | |
text: | |
- platform: template | |
name: Media Player Entity ID | |
id: media_player_entity_id | |
mode: text | |
optimistic: true | |
restore_value: true | |
entity_category: config | |
on_value: | |
then: | |
- logger.log: | |
format: "Set new media player entity: %s" | |
args: ["x.c_str()"] | |
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 | |
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/wake-word-voice-assistants/raw/main/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} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment