core: Unexpected error during wake-word-detection

The problem

I have an ESP32 satellite in the living room, which after some random amount of time (sometimes hours, sometimes a couple of days) stops responding to wake word detection. If I restart the ESP device, then wake word detection works again. Have included errors below from HA logs, which I believe are related.

The ESP32 device also has a presence sensor, and LED. Both seem to work fine without problems, and always report as expected.

What version of Home Assistant Core has the issue?

core-2023.10.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

ESPhome

Link to integration documentation on our website

https://www.home-assistant.io/integrations/esphome/

Diagnostics information

No response

Example YAML snippet

esphome:
  name: living-room-multi-sensor
  friendly_name: Living Room Multi sensor
  on_boot:
     - priority: -100
       then:
         - wait_until: api.connected
         - delay: 1s
         - if:
             condition:
               switch.is_on: use_wake_word
             then:
               - voice_assistant.start_continuous:
         - uart.write:
             id: LD1115H_UART_BUS
             data: !lambda |-
               std::string th1st = "th1=" + str_sprintf("%.0f",id(LD1115H_TH1).state) +" \n";
               return std::vector<uint8_t>(th1st.begin(), th1st.end());
         - uart.write:
             id: LD1115H_UART_BUS
             data: !lambda |-
               std::string th2st = "th2=" + str_sprintf("%.0f",id(LD1115H_TH2).state) +" \n";
               return std::vector<uint8_t>(th2st.begin(), th2st.end());   

esp32:
  board: esp32dev
  framework:
    type: esp-idf
    version: recommended

external_components:
  - source:
      type: git
      url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
    components: [ serial ]

# Enable logging
logger:
  level: DEBUG
  baud_rate: 0

# Enable Home Assistant API
api:
  encryption:
    key: "xxx"

ota:
  password: "xxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Living-Room-Multi-Sensor"
    password: "xxx"

captive_portal:
    
##### VOICE ASSISTANT #####

i2s_audio:
  i2s_lrclk_pin: GPIO27
  i2s_bclk_pin: GPIO26

microphone:
  - platform: i2s_audio
    id: mic
    adc_type: external
    i2s_din_pin: GPIO13
    pdm: false

voice_assistant:
  microphone: mic
  use_wake_word: false
  noise_suppression_level: 2
  auto_gain: 31dBFS
  volume_multiplier: 15.0
  id: assist

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(assist).set_use_wake_word(true);
      - if:
          condition:
            not:
              - voice_assistant.is_running
          then:
            - voice_assistant.start_continuous
    on_turn_off:
      - voice_assistant.stop
      - lambda: id(assist).set_use_wake_word(false);
    
##### PRESENCE SENSOR #####
  - platform: restart
    name:  Restart
    id: restart_device
uart:
  id: LD1115H_UART_BUS
  tx_pin: TX
  rx_pin: RX
  baud_rate: 115200
  data_bits: 8
  stop_bits: 1
  parity: NONE
#  debug:
#    direction: BOTH
#    dummy_receiver: false
#    after:
#      delimiter: "\n"
#    sequence:
#      - lambda: UARTDebug::log_string(direction, bytes);
globals:
  - id: LD1115H_Last_Time
    type: time_t
    restore_value: no
    initial_value: time(NULL)
  - id: LD1115H_Last_Mov_Time
    type: time_t
    restore_value: no
    initial_value: time(NULL)
  - id: LD1115H_Clearence_Status
    type: bool
    restore_value: no
    initial_value: "false"
interval:
  - interval: 1s #Clearance Scan Time
    setup_priority: -200
    then:
      lambda: |-
        if ((time(NULL)-id(LD1115H_Last_Time))>id(LD1115H_Clear_Time).state) {
          if ((id(LD1115H_Clearence_Status) == false) || (id(LD1115H_Occupancy).state != "Clearance")) {
            id(LD1115H_Occupancy).publish_state("Clearance");
            id(LD1115H_Clearence_Status) = true;
          }
          if (id(LD1115H_MovOcc_Binary).state == true) {
            id(LD1115H_MovOcc_Binary).publish_state(false);
          }
          if (id(LD1115H_Mov_Binary).state == true) {
            id(LD1115H_Mov_Binary).publish_state(false);
          }
        }
number:
  - platform: template
    name: Living room presence LD1115H TH1 #TH1 is Movement/Motion Sensitivity
    id: LD1115H_TH1
    icon: "mdi:cogs"
    optimistic: true
    restore_value: true #If you don't want to store the setting at ESP, set it to false.
    initial_value: "200" #Default TH1 Setting
    min_value: 20
    max_value: 1200
    step: 10
    set_action:
      then:
        - uart.write:
            id: LD1115H_UART_BUS
            data: !lambda |-
              std::string th1st = "th1=" + str_sprintf("%.0f",x) +" \n";
              return std::vector<uint8_t>(th1st.begin(), th1st.end());
  - platform: template
    name: Living room presence LD1115H TH2 #TH2 is Occupancy/Presence Sensitivity
    id: LD1115H_TH2
    icon: "mdi:cogs"
    optimistic: true
    restore_value: true #If you don't want to store the setting at ESP, set it to false.
    initial_value: "300" #Default TH2 Setting
    min_value: 50
    max_value: 2500
    step: 10
    set_action:
      then:
        - uart.write:
            id: LD1115H_UART_BUS
            data: !lambda |-
              std::string th2st = "th2=" + str_sprintf("%.0f",x) +" \n";
              return std::vector<uint8_t>(th2st.begin(), th2st.end());
  - platform: template
    name: Living room presence Clearence Time
    id: LD1115H_Clear_Time
    icon: "mdi:cogs"
    optimistic: true
    restore_value: true #If you don't want to store the setting at ESP, set it to false.
    initial_value: "15" #LD1115H Mov/Occ > Clearence Time Here
    min_value: 0.5
    max_value: 20
    step: 0.5
  - platform: template
    name: Living room presence Movement Time
    id: LD1115H_Mov_Time
    icon: "mdi:cogs"
    optimistic: true
    restore_value: true #If you don't want to store the setting at ESP, set it to false.
    initial_value: "5" #LD1115H Mov > Occ Time Here
    min_value: 0.5
    max_value: 10
    step: 0.5
sensor:
  - platform: template
    name: Living room presence Spectral line
    id: LD1115H_Direction
    icon: "mdi:radar"
    unit_of_measurement: ""
    accuracy_decimals: 0
  - platform: template
    name: Living room presence Signal Strength
    id: LD1115H_Signal
    icon: "mdi:signal-distance-variant"
    unit_of_measurement: ""
    accuracy_decimals: 0
    filters:    # Use Fliter To Debounce
    - sliding_window_moving_average:
        window_size: 8
        send_every: 2
    - heartbeat: 0.2s
#  - platform: adc
#    pin: A0
#    name: "LUX Sensor"
#    update_interval: '30s'
#    unit_of_measurement: lux
#    filters:
#      - lambda: |-
#          return (x / 10000.0) * -2000000.0 + 200;
text_sensor:
  - platform: serial
    uart_id: LD1115H_UART_BUS
    name: Living room presence LD1115H UART Text
    id: LD1115H_UART_Text
    icon: "mdi:format-text"
    internal: False #If Don't Want to See UART Receive Data, Set To True
    on_value:
      lambda: |-
        if (id(LD1115H_UART_Text).state.substr(0,3) == "occ") {
          id(LD1115H_Signal).publish_state(atof(id(LD1115H_UART_Text).state.substr(7).c_str()));
          id(LD1115H_Direction).publish_state(atof(id(LD1115H_UART_Text).state.substr(5,2).c_str()));
          if ((time(NULL)-id(LD1115H_Last_Mov_Time))>id(LD1115H_Mov_Time).state) {
            id(LD1115H_Occupancy).publish_state("Occupancy");
            if (id(LD1115H_MovOcc_Binary).state == false) {
              id(LD1115H_MovOcc_Binary).publish_state(true);
            }
            if (id(LD1115H_Mov_Binary).state == true) {
              id(LD1115H_Mov_Binary).publish_state(false);
            }
          }
          if (id(LD1115H_MovOcc_Binary).state == false) {
            id(LD1115H_MovOcc_Binary).publish_state(true);
          }
          id(LD1115H_Last_Time) = time(NULL);
          if (id(LD1115H_Clearence_Status) == true) {
            id(LD1115H_Clearence_Status) = false;
          }
        }
        else if (id(LD1115H_UART_Text).state.substr(0,3) == "mov") {
          id(LD1115H_Signal).publish_state(atof(id(LD1115H_UART_Text).state.substr(7).c_str()));
          id(LD1115H_Direction).publish_state(atof(id(LD1115H_UART_Text).state.substr(5,2).c_str()));
          id(LD1115H_Occupancy).publish_state("Movement");
          if (id(LD1115H_MovOcc_Binary).state == false) {
            id(LD1115H_MovOcc_Binary).publish_state(true);
          }
          if (id(LD1115H_Mov_Binary).state == false) {
            id(LD1115H_Mov_Binary).publish_state(true);
          }
          id(LD1115H_Last_Mov_Time) = time(NULL);
          id(LD1115H_Last_Time) = time(NULL);
          if (id(LD1115H_Clearence_Status) == true) {
            id(LD1115H_Clearence_Status) = false;
          }
        }
  - platform: template
    name: Living room presence Occupancy Status
    id: LD1115H_Occupancy
    icon: "mdi:motion-sensor"
binary_sensor:
  - platform: template
    name: Living room presence Occupancy or Movement
    id: LD1115H_MovOcc_Binary
    device_class: occupancy
  - platform: template
    name: Living room presence Movement
    id: LD1115H_Mov_Binary
    device_class: motion

# Light
light:
  - platform: binary
    name: "Living room satellite LED"
    output: light_output

output:
  - id: light_output
    platform: ledc
    pin: GPIO23

Anything in the logs that might be useful for us?

Logger: homeassistant.components.assist_pipeline.pipeline
Source: components/assist_pipeline/pipeline.py:653
Integration: Assist pipeline (documentation, issues)
First occurred: 30 October 2023 at 18:36:20 (37 occurrences)
Last logged: 09:13:28

Unexpected error during wake-word-detection
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/assist_pipeline/pipeline.py", line 653, in wake_word_detection
    result = await self.wake_word_entity.async_process_audio_stream(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/wake_word/__init__.py", line 112, in async_process_audio_stream
    result = await self._async_process_audio_stream(stream, wake_word_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/wyoming/wake_word.py", line 152, in _async_process_audio_stream
    chunk_info = audio_task.result()
                 ^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/wyoming/wake_word.py", line 82, in next_chunk
    async for chunk_bytes in stream:
  File "/usr/src/homeassistant/homeassistant/components/assist_pipeline/pipeline.py", line 736, in _wake_word_audio_stream
    async for chunk in audio_stream:
  File "/usr/src/homeassistant/homeassistant/components/assist_pipeline/pipeline.py", line 1147, in process_enhance_audio
    async for dirty_samples in audio_stream:
  File "/usr/src/homeassistant/homeassistant/components/esphome/voice_assistant.py", line 155, in _iterate_packets
    raise RuntimeError("Not running")
RuntimeError: Not running

Logger: homeassistant.components.assist_pipeline.pipeline
Source: components/assist_pipeline/pipeline.py:1193
Integration: Assist pipeline (documentation, issues)
First occurred: 30 October 2023 at 18:36:17 (8 occurrences)
Last logged: 09:10:46

Unexpected error in debug recording thread
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/assist_pipeline/pipeline.py", line 1193, in _pipeline_debug_recording_thread_proc
    message = queue.get(timeout=message_timeout)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/queue.py", line 179, in get
    raise Empty
_queue.Empty

Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created 8 months ago
  • Reactions: 1
  • Comments: 15

Most upvoted comments

I have the same Runtime Error, but I am running HA in docker and using an M5Stack Atom Echo.