Skip to content

Instantly share code, notes, and snippets.

@sploders101
Created May 11, 2024 20:11
Show Gist options
  • Save sploders101/a46d69fc9adf3cc17d1455004fca325e to your computer and use it in GitHub Desktop.
Save sploders101/a46d69fc9adf3cc17d1455004fca325e to your computer and use it in GitHub Desktop.
Atom Echo Configs
# Example configuration for the m5stack ATOM Echo with support for speaking through an external speaker
substitutions:
name: m5stack-atom-echo-31ace0
friendly_name: Shaun's Room Echo
speaker_entity: media_player.shaun_s_bedroom_lamp
wake_word: okay_nabu
api:
esphome:
name: ${name}
friendly_name: ${friendly_name}
name_add_mac_suffix: false
project:
name: m5stack.atom-echo-voice-assistant
version: "1.0"
min_version: 2023.11.1
esp32:
board: m5stack-atom
framework:
type: esp-idf
logger:
ota:
wifi:
ap:
ssid: !secret wifi_ssid
password: !secret wifi_password
button:
- platform: factory_reset
id: factory_reset_btn
name: Factory reset
i2s_audio:
i2s_lrclk_pin: GPIO33
i2s_bclk_pin: GPIO19
microphone:
- platform: i2s_audio
id: echo_microphone
i2s_din_pin: GPIO23
adc_type: external
pdm: true
globals:
- id: speaker_restore_volume
type: double
initial_value: '0'
- id: track_speaker_volume
type: bool
initial_value: "true"
sensor:
- platform: homeassistant
id: speaker
entity_id: ${speaker_entity}
attribute: volume_level
on_value:
then:
- if:
condition:
- lambda: 'return id(track_speaker_volume);'
then:
- globals.set:
id: speaker_restore_volume
value: !lambda return x;
voice_assistant:
id: va
microphone: echo_microphone
noise_suppression_level: 2
auto_gain: 31dBFS
volume_multiplier: 4.0
vad_threshold: 1
on_listening:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
effect: "Slow Pulse"
- globals.set:
id: track_speaker_volume
value: 'false'
- homeassistant.service:
service: media_player.volume_set
data:
volume_level: "0.1"
entity_id: ${speaker_entity}
on_stt_vad_end:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
effect: "Fast Pulse"
- globals.set:
id: track_speaker_volume
value: 'true'
- homeassistant.service:
service: media_player.volume_set
data:
entity_id: ${speaker_entity}
data_template:
volume_level: '{{ volume }}'
variables:
volume: |-
return id(speaker_restore_volume);
on_tts_start:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
brightness: 100%
effect: none
- homeassistant.service:
service: script.announce_on_shaun_s_lamp
data:
text: !lambda 'return x;'
on_end:
- micro_wake_word.start
- 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:
- micro_wake_word.start
- script.execute: reset_led
on_client_disconnected:
- if:
condition:
switch.is_on: use_wake_word
then:
- voice_assistant.stop:
- micro_wake_word.start
- light.turn_off: led
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 250ms
- OFF for at least 50ms
then:
- 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
- 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:
- micro_wake_word.start
- script.execute: reset_led
on_turn_off:
- voice_assistant.stop
- micro_wake_word.stop
- 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
external_components:
- source: github://pr#5230
components:
- esp_adf
refresh: 0s
esp_adf:
micro_wake_word:
model: ${wake_word}
on_wake_word_detected:
then:
- voice_assistant.start:
wake_word: !lambda return wake_word;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment