#M5 Stack Atom Echo - external media player config

1 messages ยท Page 1 of 1 (latest)

languid pilot
#

i'm just testing one now. will post it in here shortly ๐Ÿ‘

#

this may need a little tweaking, but tested and working so far. You'll just need to change the device name to match yours and then change the entity ID of the media player at the bottom of the voice_assistant: component block. Then the last thing to do is to allow HA service calls for the device. which you do from the ESPHome integration by clicking 'configure' next to the device. if you keep the ESPHome logs open whilst testing then you can see if there are any issues. You may need to just toggle wakeword on and off to kickstart it into life!

#

you can overwrite everything in the current yaml with this, having to paste in sections due to the line limit in discord ๐Ÿคฆโ€โ™‚๏ธ

#
esphome:
  name: m5stack-atom-echo-889258

 
esp32:
  board: m5stack-atom
  framework:
    type: esp-idf

logger:
api:
  on_client_connected:
    - delay: 100ms
    - 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
ota:
wifi:
  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

# speaker:
  # - platform: i2s_audio
    # id: echo_speaker
    # i2s_dout_pin: GPIO22
    # dac_type: external
    # mode: mono
#
voice_assistant:
  id: va
  microphone: echo_microphone
  # speaker: echo_speaker
  noise_suppression_level: 2
  # auto_gain: 31dBFS
  volume_multiplier: 2.0
  # vad_threshold: 3
  on_listening:
    - light.turn_on:
        id: led
        blue: 100%
        red: 0%
        green: 0%
        effect: "Slow Pulse"
  on_stt_vad_start:
    - light.turn_on:
        id: led
        blue: 0%
        red: 100%
        green: 0%
        effect: "Fast Pulse"
  on_stt_vad_end:
    - light.turn_on:
        id: led
        blue: 100%
        red: 0%
        green: 0%
        effect: "Fast Pulse"
  on_tts_start:
    - light.turn_on:
        id: led
        blue: 100%
        red: 0%
        green: 0%
        brightness: 100%
        effect: none
  on_end:
    - delay: 500ms

    - 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_tts_end:
        then:
          - homeassistant.service:
              service: media_player.play_media
              data:
                entity_id: media_player.colins_voice
                media_content_id: !lambda 'return x;'
                media_content_type: music

#
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: 30%
                blue: 100%
                brightness: 60%
                effect: none
            - voice_assistant.start_continuous:
          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

# external_components:
  # - source: github://pr#5230
    # components:
      # - esp_adf
    # refresh: 0s

# esp_adf:
#

i've commented out the speaker config and a couple of other things that help! or just don't do anything ๐Ÿ™‚ so that you can re-enable speaker easily if required. Good Luck!! and ping me if you need any pointers ๐Ÿ‘

#

M5 Stack Atom Echo - external media player config

jagged pumice
#

Will give it a go in a few, and report back! Thanks again

languid pilot
#

your'e welcome

true agateBOT
#

Please use a code share site to share code or logs, for example:

Please don't use Pastebin, since it can randomly add spaces to the main view. Please also don't share text as images since it makes it harder for people to help you. Remember that others may have colour blindness, impaired vision, etc.

languid pilot
jagged pumice
#

Alright alright alright!!! That seems to be working pretty well!!

#

thanks @languid pilot !!

languid pilot
#

ah great stuff ๐ŸŽ‰

#

i'm going to keep it running myself for a few days so if you come accross any issues drop us a ping in here ๐Ÿ‘

jagged pumice
#

I'm actually super surprised with how Well it works now ๐Ÿคฃ. I was pretty disapointed with the issues i was having since i got three of those little guys. Now i'm happy again ๐Ÿคฃ

#

I'm gonna try to make sonos speaker resume playing music after it finishes the tss message

languid pilot
#

yes thats something I was going to look into too, also lowering the volume on wakeword ๐Ÿ˜

lavish coral
#

What speakers do you guys use and like? I also got 3 of these and like everyone else have discovere d the speaker is pretty bad. I don't have any media players connected to my HA though so I'd need to get some, but I've no idea what's suitable.

#

Something bluetooth connected is probably not an option, is there even a protocol for something network/wifi connected?

languid pilot
jagged pumice
lavish coral
#

How do they connect?

jagged pumice