Updated Voice Assistant sattelites

This commit is contained in:
Marcus Scholz 2025-01-06 09:12:47 +01:00
parent 373675be4f
commit 99007cda76
2 changed files with 254 additions and 56 deletions

View File

@ -7,14 +7,14 @@ esphome:
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
name_add_mac_suffix: False name_add_mac_suffix: False
project: project:
name: m5stack.atom-echo name: m5stack.atom-echo-voice-assistant
version: "1.0" version: "24.7.24"
min_version: 2023.5.0 min_version: 2024.9.0
esp32: esp32:
board: m5stack-atom board: m5stack-atom
framework: framework:
type: arduino type: esp-idf
# Enable Home Assistant API # Enable Home Assistant API
api: api:
@ -22,10 +22,26 @@ api:
key: !secret apikey key: !secret apikey
ota: ota:
platform: esphome - platform: esphome
password: !secret ota password: !secret ota
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/voice-assistant/m5stack-atom-echo/manifest.json
http_request:
wifi: wifi:
on_connect:
- delay: 5s # Gives time for improv results to be transmitted
- ble.disable:
on_disconnect:
- ble.enable:
ssid: Voltage-legacy ssid: Voltage-legacy
password: !secret voltage_legacy_psk password: !secret voltage_legacy_psk
use_address: ${name}.home use_address: ${name}.home
@ -36,18 +52,30 @@ wifi:
ssid: "Raspiaudio Fallback Hotspot" ssid: "Raspiaudio Fallback Hotspot"
password: !secret fallback_psk password: !secret fallback_psk
improv_serial:
esp32_improv:
authorizer: none
logger: logger:
dashboard_import: dashboard_import:
package_import_url: github://esphome/media-players/m5stack-atom-echo.yaml@main package_import_url: github://esphome/firmware/voice-assistant/m5stack-atom-echo.adopted.yaml@main
captive_portal: captive_portal:
improv_serial: button:
- platform: safe_mode
id: button_safe_mode
name: Safe Mode Boot
- platform: factory_reset
id: factory_reset_btn
name: Factory reset
i2s_audio: i2s_audio:
i2s_lrclk_pin: GPIO33 - id: i2s_audio_bus
i2s_bclk_pin: GPIO19 i2s_lrclk_pin: GPIO33
i2s_bclk_pin: GPIO19
microphone: microphone:
- platform: i2s_audio - platform: i2s_audio
@ -56,45 +84,103 @@ microphone:
adc_type: external adc_type: external
pdm: true pdm: true
speaker:
- platform: i2s_audio
id: echo_speaker
i2s_dout_pin: GPIO22
dac_type: external
channel: mono
voice_assistant: voice_assistant:
id: va
microphone: echo_microphone microphone: echo_microphone
on_start: speaker: echo_speaker
noise_suppression_level: 2
auto_gain: 31dBFS
volume_multiplier: 2.0
vad_threshold: 3
on_listening:
- light.turn_on: - light.turn_on:
id: led id: led
blue: 100% blue: 100%
red: 0% red: 0%
green: 0% green: 0%
effect: none effect: "Slow Pulse"
on_stt_vad_end:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
effect: "Fast Pulse"
on_tts_start: on_tts_start:
- light.turn_on: - light.turn_on:
id: led id: led
blue: 0% blue: 100%
red: 0% red: 0%
green: 100% green: 0%
brightness: 100%
effect: none effect: none
on_tts_end:
- media_player.play_media: !lambda return x;
- light.turn_on:
id: led
blue: 0%
red: 0%
green: 100%
effect: pulse
on_end: on_end:
- delay: 1s - delay: 100ms
- wait_until: - wait_until:
not: not:
media_player.is_playing: media_out speaker.is_playing:
- light.turn_off: led - script.execute: reset_led
on_error: on_error:
- light.turn_on: - light.turn_on:
id: led id: led
blue: 0%
red: 100% red: 100%
green: 0% green: 0%
blue: 0%
brightness: 100%
effect: none effect: none
- delay: 1s - 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:
- voice_assistant.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 - 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
binary_sensor: binary_sensor:
- platform: gpio - platform: gpio
@ -102,35 +188,48 @@ binary_sensor:
number: GPIO39 number: GPIO39
inverted: true inverted: true
name: Button name: Button
disabled_by_default: true
entity_category: diagnostic
id: echo_button id: echo_button
on_multi_click: on_multi_click:
- timing: - timing:
- ON FOR AT MOST 350ms - ON for at least 50ms
- OFF FOR AT LEAST 10ms - OFF for at least 50ms
then: then:
- media_player.toggle: media_out - 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: - timing:
- ON FOR AT LEAST 350ms - ON for at least 10s
then: then:
- voice_assistant.start: - button.press: factory_reset_btn
- timing:
- ON FOR AT LEAST 350ms
- OFF FOR AT LEAST 10ms
then:
- voice_assistant.stop:
media_player:
- platform: i2s_audio
id: media_out
name: None
dac_type: external
i2s_dout_pin: GPIO22
mode: mono
light: light:
- platform: esp32_rmt_led_strip - platform: esp32_rmt_led_strip
id: led id: led
name: None name: None
disabled_by_default: true
entity_category: config
pin: GPIO27 pin: GPIO27
default_transition_length: 0s default_transition_length: 0s
chipset: SK6812 chipset: SK6812
@ -139,5 +238,89 @@ light:
rmt_channel: 0 rmt_channel: 0
effects: effects:
- pulse: - pulse:
name: "Slow Pulse"
transition_length: 250ms transition_length: 250ms
update_interval: 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:
type: git
url: https://github.com/jesserockz/esphome-components
ref: main
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

View File

@ -8,8 +8,9 @@ api:
key: !secret apikey key: !secret apikey
ota: ota:
platform: esphome - platform: esphome
password: !secret ota id: ota_esphome
password: !secret ota
wifi: wifi:
ssid: Voltage-legacy ssid: Voltage-legacy
@ -29,7 +30,7 @@ esphome:
project: project:
name: raspiaudio.muse-luxe name: raspiaudio.muse-luxe
version: "1.0" version: "1.0"
min_version: 2023.5.0 min_version: 2024.6.0
on_boot: on_boot:
then: then:
- media_player.volume_set: - media_player.volume_set:
@ -44,25 +45,25 @@ esp32:
logger: logger:
i2c: i2c:
sda: GPIO18 - id: i2c_bus
scl: GPIO23 sda: GPIO18
scl: GPIO23
dashboard_import: dashboard_import:
package_import_url: github://esphome/media-players/raspiaudio-muse-luxe.yaml@main package_import_url: github://esphome/media-players/raspiaudio-muse-luxe.yaml@main
captive_portal: captive_portal:
improv_serial:
external_components: external_components:
- source: github://pr#3552 # DAC support https://github.com/esphome/esphome/pull/3552 - source: github://pr#3552 # DAC support https://github.com/esphome/esphome/pull/3552
components: [es8388] components: [es8388]
refresh: 0s refresh: 0s
es8388: es8388:
i2s_audio: i2s_audio:
- i2s_lrclk_pin: GPIO25 - id: i2s_audio_bus
i2s_lrclk_pin: GPIO25
i2s_bclk_pin: GPIO5 i2s_bclk_pin: GPIO5
media_player: media_player:
@ -125,6 +126,7 @@ voice_assistant:
sensor: sensor:
- platform: adc - platform: adc
id: battery_sensor
pin: GPIO33 pin: GPIO33
name: Battery name: Battery
icon: "mdi:battery-outline" icon: "mdi:battery-outline"
@ -137,12 +139,13 @@ sensor:
attenuation: 11db attenuation: 11db
raw: true raw: true
filters: filters:
- multiply: 0.00173913 # 2300 -> 4, for attenuation 11db, based on Olivier's code - multiply: 0.00173913 # 2300 -> 4, for attenuation 11db, based on Olivier's code
- exponential_moving_average: - exponential_moving_average:
alpha: 0.2 alpha: 0.2
send_every: 2 send_every: 2
- delta: 0.002 - delta: 0.002
binary_sensor: binary_sensor:
- platform: gpio - platform: gpio
pin: pin:
@ -152,6 +155,7 @@ binary_sensor:
input: true input: true
pullup: true pullup: true
name: Volume Up name: Volume Up
id: volume_up
on_click: on_click:
- media_player.volume_up: luxe_out - media_player.volume_up: luxe_out
- platform: gpio - platform: gpio
@ -162,6 +166,7 @@ binary_sensor:
input: true input: true
pullup: true pullup: true
name: Volume Down name: Volume Down
id: volume_down
on_click: on_click:
- media_player.volume_down: luxe_out - media_player.volume_down: luxe_out
- platform: gpio - platform: gpio
@ -172,6 +177,7 @@ binary_sensor:
input: true input: true
pullup: true pullup: true
name: Action name: Action
id: action_button
on_multi_click: on_multi_click:
- timing: - timing:
- ON FOR AT MOST 350ms - ON FOR AT MOST 350ms
@ -200,4 +206,13 @@ light:
effects: effects:
- pulse: - pulse:
transition_length: 250ms transition_length: 250ms
update_interval: 250ms update_interval: 250ms
button:
- platform: safe_mode
id: button_safe_mode
name: Safe Mode Boot
- platform: factory_reset
id: factory_reset_btn
name: Factory reset