Compare commits

...

4 Commits

Author SHA1 Message Date
7221213ac4 Rework Voice, Microphone, and MWW handling
Needed for recent changes in ESPHome and to properly align us with the
most recent developments. Includes support for multiple selectable wake
words as well.
2025-05-23 23:17:54 -04:00
28b76d0508 Adjust threshold values and set min_version 2025-05-23 22:57:36 -04:00
647e6711b8 Remove CPU frequency
Doesn't work on recent ESP-IDF versions it seems.
2025-05-21 16:57:38 -04:00
7d5d7da2e8 Remove esp-adf component
This causes numerous issues now, so remove it.
2025-05-21 16:54:32 -04:00

View File

@ -27,6 +27,7 @@ esphome:
project: project:
name: joshuaboniface.supersensor name: joshuaboniface.supersensor
version: "2.0" version: "2.0"
min_version: 2025.5.0
on_boot: on_boot:
- priority: 600 - priority: 600
then: then:
@ -38,19 +39,9 @@ esphome:
- light.turn_on: - light.turn_on:
id: output_led id: output_led
effect: flash_white effect: flash_white
- priority: -600
then: preferences:
- wait_until: flash_write_interval: 15sec
api.connected:
- delay: 5s
- if:
condition:
switch.is_on: enable_voice_support
then:
- logger.log: "Initializing voice assistant on boot"
- switch.turn_off: voice_support_active
- delay: 2s
- switch.turn_on: voice_support_active
dashboard_import: dashboard_import:
package_import_url: github://joshuaboniface/supersensor2/supersensor.yaml package_import_url: github://joshuaboniface/supersensor2/supersensor.yaml
@ -59,8 +50,6 @@ esp32:
board: esp32dev board: esp32dev
framework: framework:
type: esp-idf type: esp-idf
version: 4.4.8
platform_version: 5.4.0
sdkconfig_options: sdkconfig_options:
CONFIG_ESP32_DEFAULT_CPU_FREQ_240: "y" CONFIG_ESP32_DEFAULT_CPU_FREQ_240: "y"
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "240" CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "240"
@ -259,28 +248,28 @@ script:
id(supersensor_occupancy).publish_state(new_state); id(supersensor_occupancy).publish_state(new_state);
} }
preferences:
flash_write_interval: 15sec
logger: logger:
level: INFO level: INFO
baud_rate: 115200 baud_rate: 115200
api: api:
reboot_timeout: 15min reboot_timeout: 15min
services: on_client_connected:
- service: restart_voice_assistant - script.execute: light_off
then: - if:
- logger.log: "Manually restarting voice assistant" condition:
- voice_assistant.stop: - switch.is_on: enable_voice_support
- delay: 2s then:
- if: - micro_wake_word.start:
condition: on_client_disconnected:
switch.is_on: enable_voice_support - light.turn_on:
then: id: output_led
- switch.turn_off: voice_support_active effect: flash_white
- delay: 1s - if:
- switch.turn_on: voice_support_active condition:
- switch.is_on: enable_voice_support
then:
- micro_wake_word.stop:
ota: ota:
platform: esphome platform: esphome
@ -307,44 +296,7 @@ time:
then: then:
- logger.log: "Time synchronized with Home Assistant" - logger.log: "Time synchronized with Home Assistant"
uart:
id: ld2410_uart
rx_pin: GPIO19
tx_pin: GPIO18
baud_rate: 256000
data_bits: 8
stop_bits: 1
parity: NONE
i2c:
sda: GPIO27
scl: GPIO26
scan: true
i2s_audio:
i2s_lrclk_pin: GPIO17 # WS
i2s_bclk_pin: GPIO16 # SCK
microphone:
- platform: i2s_audio
id: mic
adc_type: external
i2s_din_pin: GPIO4 # SD
pdm: false
interval: interval:
- interval: 5s
then:
- if:
condition:
and:
- switch.is_on: enable_voice_support
- switch.is_on: voice_support_active
- not: voice_assistant.is_running
then:
- logger.log: "Voice assistant not running but should be; restarting"
- voice_assistant.start_continuous:
# Regular state reporting to HASS # Regular state reporting to HASS
- interval: 30s - interval: 30s
then: then:
@ -364,59 +316,72 @@ interval:
App.safe_reboot(); App.safe_reboot();
} }
uart:
id: ld2410_uart
rx_pin: GPIO19
tx_pin: GPIO18
baud_rate: 256000
data_bits: 8
stop_bits: 1
parity: NONE
i2c:
sda: GPIO27
scl: GPIO26
scan: true
i2s_audio:
- id: i2s_input
i2s_lrclk_pin:
number: GPIO17 # WS
i2s_bclk_pin:
number: GPIO16 # SCK
microphone:
- platform: i2s_audio
id: mic
i2s_audio_id: i2s_input
i2s_din_pin: GPIO4 # SD
adc_type: external
pdm: false
channel: left
micro_wake_word: micro_wake_word:
id: mww
microphone:
microphone: mic
gain_factor: 31
stop_after_detection: false
models: models:
- model: hey_jarvis - model: hey_jarvis
id: mww_hey_jarvis
- model: hey_mycroft
id: mww_hey_mycroft
- model: ok_nabu
id: mww_okay_nabu
- model: alexa
id: mww_alexa
vad:
on_wake_word_detected: on_wake_word_detected:
then: - logger.log: "A wake word was detected!"
- voice_assistant.start: - if:
wake_word: !lambda return wake_word; condition:
voice_assistant.is_running:
# Include the Espressif Audio Development Framework for VAD support then:
esp_adf: voice_assistant.stop:
external_components: - voice_assistant.start:
- source: github://pr#5230 wake_word: !lambda return wake_word;
components:
- esp_adf
refresh: 0s
voice_assistant: voice_assistant:
id: va
microphone: mic microphone: mic
micro_wake_word: mww
use_wake_word: false use_wake_word: false
noise_suppression_level: 3 noise_suppression_level: 0
auto_gain: 31dBFS auto_gain: 31 dbfs
volume_multiplier: 8.0 volume_multiplier: 8
id: assist
on_error:
- logger.log: "voice error"
- if:
condition:
and:
- switch.is_on: voice_support_active
- not: voice_assistant.is_running
then:
- voice_assistant.start_continuous:
on_end:
- logger.log: "voice ended"
- if:
condition:
and:
- switch.is_on: voice_support_active
- not: voice_assistant.is_running
then:
- voice_assistant.start_continuous:
on_client_connected:
- light.turn_off:
id: output_led
transition_length: 2s
- script.execute: light_off
- lambda: |-
id(voice_support_active).publish_state(true);
on_client_disconnected:
- light.turn_on:
id: output_led
effect: flash_white
on_wake_word_detected: on_wake_word_detected:
- logger.log: "Wake word detected in VA pipeline"
- light.turn_on: - light.turn_on:
id: output_led id: output_led
brightness: 100% brightness: 100%
@ -424,6 +389,7 @@ voice_assistant:
green: 0 green: 0
blue: 1 blue: 1
on_listening: on_listening:
- logger.log: "Listening for commands"
- light.turn_on: - light.turn_on:
id: output_led id: output_led
brightness: 100% brightness: 100%
@ -431,14 +397,13 @@ voice_assistant:
green: 0 green: 0
blue: 1 blue: 1
on_stt_vad_end: on_stt_vad_end:
- logger.log: "Processing STT result"
- light.turn_on: - light.turn_on:
id: output_led id: output_led
brightness: 75% brightness: 75%
red: 0 red: 0
green: 1 green: 1
blue: 1 blue: 1
on_stt_end:
- script.execute: light_off
on_tts_start: on_tts_start:
- if: - if:
condition: condition:
@ -685,16 +650,6 @@ sensor:
update_interval: 5s update_interval: 5s
entity_category: diagnostic entity_category: diagnostic
- platform: template
name: "ESP32 CPU Frequency"
icon: mdi:cpu-32-bit
accuracy_decimals: 1
unit_of_measurement: MHz
update_interval: 5s
lambda: |-
return ets_get_cpu_frequency();
entity_category: diagnostic
- platform: template - platform: template
name: "ESP32 Free Memory" name: "ESP32 Free Memory"
icon: mdi:memory icon: mdi:memory
@ -718,7 +673,9 @@ binary_sensor:
- platform: gpio - platform: gpio
name: "PIR GPIO" name: "PIR GPIO"
id: pir_gpio id: pir_gpio
pin: GPIO32 pin:
number: GPIO32
mode: INPUT_PULLUP
internal: false internal: false
device_class: motion device_class: motion
on_press: on_press:
@ -789,26 +746,9 @@ switch:
optimistic: true optimistic: true
restore_mode: RESTORE_DEFAULT_OFF restore_mode: RESTORE_DEFAULT_OFF
on_turn_on: on_turn_on:
- switch.turn_on: voice_support_active - micro_wake_word.start:
on_turn_off: on_turn_off:
- switch.turn_off: voice_support_active - micro_wake_word.stop:
# Active voice support flag/switch
- platform: template
name: "Voice Support Active"
icon: mdi:account-voice
id: voice_support_active
optimistic: true
restore_mode: ALWAYS_OFF
entity_category: config
on_turn_on:
- lambda: id(assist).set_use_wake_word(true);
- voice_assistant.stop:
- delay: 1s
- voice_assistant.start_continuous:
on_turn_off:
- voice_assistant.stop:
- lambda: id(assist).set_use_wake_word(false);
# Global enable/disable for presence LED # Global enable/disable for presence LED
- platform: template - platform: template
@ -832,12 +772,12 @@ switch:
number: number:
# Temperature offset: # Temperature offset:
# A calibration from -10 to +5 for the temperature sensor # A calibration from -30 to +5 for the temperature sensor
- platform: template - platform: template
name: "Temperature Offset" name: "Temperature Offset"
id: temperature_offset_setter id: temperature_offset_setter
min_value: -10 min_value: -30
max_value: 5 max_value: 10
step: 0.1 step: 0.1
lambda: |- lambda: |-
return id(temperature_offset); return id(temperature_offset);
@ -848,12 +788,12 @@ number:
value: !lambda 'return float(x);' value: !lambda 'return float(x);'
# Humidity offset: # Humidity offset:
# A calibration from -10 to +10 for the humidity sensor # A calibration from -20 to +20 for the humidity sensor
- platform: template - platform: template
name: "Humidity Offset" name: "Humidity Offset"
id: humidity_offset_setter id: humidity_offset_setter
min_value: -10 min_value: -20
max_value: 10 max_value: 20
step: 0.1 step: 0.1
lambda: |- lambda: |-
return id(humidity_offset); return id(humidity_offset);
@ -951,7 +891,6 @@ number:
name: "LD2410C Gate8 Still Threshold" name: "LD2410C Gate8 Still Threshold"
select: select:
# Occupancy Detect Mode: # Occupancy Detect Mode:
# This selector defines the detection mode for the integrated occupancy sensor. Depending on the # This selector defines the detection mode for the integrated occupancy sensor. Depending on the
# selected option, only the given sensor(s) will be used to judge when occupancy begins (i.e. # selected option, only the given sensor(s) will be used to judge when occupancy begins (i.e.
@ -1080,6 +1019,39 @@ select:
distance_resolution: distance_resolution:
name: "LD2410C Distance Resolution" name: "LD2410C Distance Resolution"
- platform: template
name: "Wake word sensitivity"
optimistic: true
initial_option: Moderately sensitive
restore_value: true
entity_category: config
options:
- Slightly sensitive
- Moderately sensitive
- Very sensitive
on_value:
# Sets specific wake word probabilities computed for each particular model
# Note probability cutoffs are set as a quantized uint8 value, each comment has the corresponding floating point cutoff
# False Accepts per Hour values are tested against all units and channels from the Dinner Party Corpus.
# These cutoffs apply only to the specific models included in the firmware: okay_nabu@20241226.3, hey_jarvis@v2, hey_mycroft@v2
lambda: |-
if (x == "Slightly sensitive") {
id(mww_jarvis).set_probability_cutoff(247); // 0.97 -> 0.563 FAPH on DipCo (Manifest's default)
id(mww_hey_mycroft).set_probability_cutoff(253); // 0.99 -> 0.567 FAPH on DipCo
id(mww_okay_nabu).set_probability_cutoff(217); // 0.85 -> 0.000 FAPH on DipCo (Manifest's default)
id(mww_alexa).set_probability_cutoff(217); // 0.85 -> 0.000 FAPH on DipCo (Manifest's default)
} else if (x == "Moderately sensitive") {
id(mww_hey_jarvis).set_probability_cutoff(235); // 0.92 -> 0.939 FAPH on DipCo
id(mww_hey_mycroft).set_probability_cutoff(242); // 0.95 -> 1.502 FAPH on DipCo (Manifest's default)
id(mww_okay_nabu).set_probability_cutoff(176); // 0.69 -> 0.376 FAPH on DipCo
id(mww_alexa).set_probability_cutoff(176); // 0.69 -> 0.376 FAPH on DipCo
} else if (x == "Very sensitive") {
id(mww_hey_jarvis).set_probability_cutoff(212); // 0.83 -> 1.502 FAPH on DipCo
id(mww_hey_mycroft).set_probability_cutoff(237); // 0.93 -> 1.878 FAPH on DipCo
id(mww_okay_nabu).set_probability_cutoff(143); // 0.56 -> 0.751 FAPH on DipCo
id(mww_alexa).set_probability_cutoff(143); // 0.56 -> 0.751 FAPH on DipCo
}
text_sensor: text_sensor:
- platform: wifi_info - platform: wifi_info
ip_address: ip_address: