diff --git a/ESPhome/hass-assist/assist-stereo.yaml b/ESPhome/hass-assist/assist-stereo.yaml new file mode 100644 index 0000000..2806094 --- /dev/null +++ b/ESPhome/hass-assist/assist-stereo.yaml @@ -0,0 +1,119 @@ +esphome: + name: assistant-desk + friendly_name: Assistant Desk + +esp32: + board: esp32doit-devkit-v1 + framework: + type: esp-idf + +logger: + level: DEBUG + +# Enable Home Assistant API +api: + password: "" + +ota: + password: "" + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "Bed-Scale Fallback Hotspot" + password: !secret hotspot_password +i2s_audio: + - id: i2s_in + i2s_lrclk_pin: GPIO26 #WS / LRC + i2s_bclk_pin: GPIO25 #SCK /BCLK + +microphone: + - platform: i2s_audio + adc_type: external + pdm: false + id: mic_i2s + channel: right + bits_per_sample: 32bit + i2s_audio_id: i2s_in + i2s_din_pin: GPIO33 #SD + +speaker: + - platform: i2s_audio + id: my_speaker + dac_type: external + i2s_dout_pin: GPIO14 #DIN + mode: stereo + i2s_audio_id: i2s_in + +voice_assistant: + microphone: mic_i2s + id: va + noise_suppression_level: 2 + auto_gain: 31dBFS + volume_multiplier: 4.0 + use_wake_word: false + speaker: my_speaker + + on_error: + - if: + condition: + switch.is_on: use_wake_word + then: + - switch.turn_off: use_wake_word + - switch.turn_on: use_wake_word + + on_client_connected: + - if: + condition: + switch.is_on: use_wake_word + then: + - voice_assistant.start_continuous: + + on_client_disconnected: + - if: + condition: + switch.is_on: use_wake_word + then: + - voice_assistant.stop: + +binary_sensor: + - platform: status + name: API Connection + id: api_connection + filters: + - delayed_on: 1s + on_press: + - if: + condition: + switch.is_on: use_wake_word + then: + - voice_assistant.start_continuous: + on_release: + - if: + condition: + switch.is_on: use_wake_word + then: + - voice_assistant.stop: + +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 + + on_turn_off: + - voice_assistant.stop + - lambda: id(va).set_use_wake_word(false);