Problem when trying to create Assist in M5Stack atom echo using mqtt

Hello, I’m trying to create an assistant on an M5Stack Atom Echo capable of being used outside of my home network, to put it inside a The Mandalorian helmet that I’m building.

For this I thought of using this code:

esphome:
  name: m5stackatomecho_assist
  friendly_name: M5StackAtomEcho Assist
  name_add_mac_suffix: true
  project:
    name: m5stack.atom-echo-voice-assistant
    version: "1.0"
  min_version: 2024.2.0

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

logger:
api:
  encryption:
    key: "*****"
ota:
  password: "*****"

dashboard_import:
  package_import_url: github://esphome/firmware/voice-assistant/m5stack-atom-echo.yaml@main

wifi:
  output_power: 18
  on_connect:
    - delay: 5s  # Gives time for improv results to be transmitted
    - ble.disable:
  on_disconnect:
    - ble.enable:
  ssid: "*****"
  password: "*****"

  # Optional manual IP
  #manual_ip:
  #  static_ip: 192.168.1.30
  #  gateway: 192.168.1.1
  #  subnet: 255.255.255.0

improv_serial:

esp32_improv:
  authorizer: none

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_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_tts_end:
  - homeassistant.service:
      service: media_player.play_media
      data:
        entity_id: media_player.wohnzimmer #add your media player here
        media_content_id: !lambda 'return x;'
        media_content_type: music
        announce: "true"
  on_end:
    - delay: 100ms
    - wait_until:
        not:
          speaker.is_playing:
    - 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_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

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
                - voice_assistant.start_continuous:
      - 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: 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

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

esp_adf:

taken from this page, only edited changing the api to mqtt:
https://community.home-assistant.io/t/a-silly-simple-question-about-esphome-specifically-m5stack-atom-echo-firmware/674850/5

My problem is that, when loading the code, I get this:
image

and this:

Window, after that I get this error:

========================= [SUCCESS] Took 58.04 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 172.16.2.26
INFO Uploading /data/build/m5stackatomecho_assist-30592c/.pioenvs/m5stackatomecho_assist-30592c/firmware.bin (1606720 bytes)
ERROR ESP requests password, but no password given!

and if I go inside the .yalm file that it created for me, it looks nothing like the original:

substitutions:
  name: m5stackatomecho_assist-30592c
  friendly_name: GE00_M5StackAtomEcho
packages:
  m5stack.atom-echo-voice-assistant: github://esphome/firmware/voice-assistant/m5stack-atom-echo.yaml@main
esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}
api:
  encryption:
    key: *****


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

I emphasize that I have not yet tried integrating it with mqtt, first I want to see if I can get an editable code to be able to play with it

Can anyone give me any ideas?

1 Like

I’m sorry, seems I’m a little slow on the uptake today, but what is your question? :slight_smile:

What you’re doing with your configuration, you load a preconfigured script from Github. That’s what gets imported into ESPHome.

The script that gets loaded is in this line

packages:
  m5stack.atom-echo-voice-assistant: github://esphome/firmware/voice-assistant/m5stack-atom-echo.yaml@main

You can find it here:

The imported script replaces your configuration.

Does that help or am I totally off? :slight_smile:

1 Like

Hello, sorry for the delay, I’ve had a difficult few weeks.

I had already found that code, but I have not been able to adapt it to my project, what I need to get is the final code, that is, a code that I upload to the esp32c3 and it works (without having to readopt it since it creates a second device that disappears when turned off), once I found that code I can try to adapt it for mqtt

Hi there! :slight_smile:

Not a problem, but I still don’t get, what you’re trying to do or better, I don’t understand why you want to do things the way you do them. :slight_smile:

But let’s see, if we can get there! :smiley:

What is it, that you want to achieve? Please tell exactly, what it is you want. Assist in a mandalorian helmet to do what? How do you want to use that? just explain, what your “end-product” should be, so we can figure out the best way, to get there!

I think we should start with a little more basic things, before you adopt anything. :wink:

  • You have HA running how (installation method)? I guess HA-OS, but to be sure…
  • ESPHome is installed as an add-on?
  • Have you worked with ESPHome before and/or have other devices in ESPHome?

Normally, this is run like this:

  • HA-OS
  • ESPHome add-on (that’s where you configure a device with YAML code and the firmware gets compiled)
  • ESPHome integration into HA (that’s where the ESP device connects with HA to control and/or get some sensor values)

What you’d need to do is:

  • Configure a firmware for your device (the M5Stack ATOM) in ESPHome add-on
  • Let it compile and OTA it to the device
  • Discover the device in ESPHome integration in HA and use it

To configure the firmware, you need to setup a device in the ESPHome add-on. Right now, this config data is taken from the link at Github and gets downloaded into ESPHome add-on. So in theory, you’re taking the content of that file and paste it into your ESPHome add-on (manually or by donwload) to get a firmware.

Just let me know a little more about your setup/installation, and we’ll get there! :slight_smile:

PS: You do realize that at least I want to see pictures of what you’re building here! Without pics it didn’t happen. :rofl:

Hello, I have been trying more things, and I have gotten a little burned with it, it occurred to me to use an Alexa Echo Auto to perform this action, in more or less a week, I will surely be able to buy one, I will try to test it and I will update it here

Here are the first two pieces joined together… for now it’s been 16 hours and I’m only doing a quarter of it