WTH M5stack Atom Echo never shows up as Media Player target in HA?

I did install this using few several methods: using preinstaller from web, using manual yaml etc… there is no media player service endpoint created for it. :frowning:

this my latest config from m5stack.yaml after adoption:

substitutions:
  name: m5stack
packages:
  m5stack.atom-echo: github://esphome/media-players/m5stack-atom-echo.yaml@main
esphome:
  name: ${name}
  name_add_mac_suffix: false
ota:
  password: !secret ota_password
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

Hi,

Probably , you have already sort this out but here it goes for anyone still looking for:

media_player:

  - platform: i2s_audio

    id: media_out

    name: None

    dac_type: external

    i2s_dout_pin: GPIO22

    mode: mono
1 Like

This is an issue I am currently having. As I am new to Home Assistant I am fumbling my way around and learning. That said, I have no idea where this code is supposed to go. Can someone enlighten me, please?

@freedombeard I would say it goes into your ESPhome YAML code, which you can edit in the ESPHome dashboard by clicking “Edit” next to the device name

Ah, that was a major part of my problem; I hadn’t installed ESPhome. Home Assistant had automatically added the Atom Echos it found.

So, now I’ve installed ESPhome and added the device. My yaml file looks exactly like OP’s now. I can now add the above media_player code from @miguelromao but I get this error: “This feature is only available with frameworks [‘arduino’].”

My assumption is that media_player is already defined in (and copied/installed to the device itself):

If so, how do I call it in an automation? So far as Home Assistant is concerned a media_player.m5stack-atom-echo-xxxx does not exist. I can manually type it in (replacing - with _) and the automation runs without error. But, it does not actually play the text to speech phrase I’ve told it to (via PiperTTS.)

I added the following to my atom echo esphome configuration and the media player now shows up and works.

1 Like

Can you paste the YAML code please. Makes it easier to copy/try out.

Just add this to your existing esphome yaml configuration and install it on the atom echo.

esp32:
  board: m5stack-atom
  framework:
    type: arduino
media_player:
  platform: i2s_audio
  id: media_out
  name: None
  dac_type: external
  i2s_dout_pin: GPIO22
  mode: mono
1 Like

The biggest problem I’ve had with using the Atom Echos as a media_player is that every time I try to play something on it, the first time it seems to work but subsequently trying to play another MP3 sets the thing in “busted” mode and it no longer plays any music nor speech until I reboot it. It’s like the media_player looses it’s mind or something. Not very useful.

I’m having a similar issue. I dont ever get media playing. I have installed the voice assistant, so I know the speaker works. I reinstalled. My config for the M5Stack Echo Atom:

esphome: name: m5stack-atom-echo friendly_name: M5Stack Atom Echo name_add_mac_suffix: true project: name: m5stack.atom-echo version: "1.0" min_version: 2023.5.0

esp32:
board: m5stack-atom
framework:
type: arduino

logger:
api:
ota:

dashboard_import:
package_import_url: github://esphome/firmware/media-player/m5stack-atom-echo.yaml@main

wifi:
ap:

captive_portal:

improv_serial:

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

voice_assistant:
microphone: echo_microphone
on_start:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
effect: none
on_tts_start:
- light.turn_on:
id: led
blue: 0%
red: 0%
green: 100%
effect: none
on_tts_end:
- media_player.play_media: !lambda return x;
- light.turn_on:
id: led
blue: 0%
red: 0%
green: 100%
effect: pulse
on_end:
- delay: 1s
- wait_until:
not:
media_player.is_playing: media_out
- light.turn_off: led
on_error:
- light.turn_on:
id: led
blue: 0%
red: 100%
green: 0%
effect: none
- delay: 1s
- light.turn_off: led

binary_sensor:

  • platform: gpio
    pin:
    number: GPIO39
    inverted: true
    name: Button
    id: echo_button
    on_multi_click:
    • timing:
      • ON FOR AT MOST 350ms
      • OFF FOR AT LEAST 10ms
        then:
      • media_player.toggle: media_out
    • timing:
      • ON FOR AT LEAST 350ms
        then:
      • if:
        condition:
        media_player.is_playing: media_out
        then:
        - media_player.stop: media_out
      • voice_assistant.start:
    • timing:
      • ON FOR AT LEAST 350ms
      • OFF FOR AT LEAST 10ms
        then:
      • voice_assistant.stop:

media_player:

  • platform: i2s_audio
    id: media_out
    name: None
    dac_type: external
    i2s_dout_pin: GPIO22
    mode: mono

light:

  • platform: esp32_rmt_led_strip
    id: led
    name: None
    pin: GPIO27
    default_transition_length: 0s
    chipset: SK6812
    num_leds: 1
    rgb_order: grb
    rmt_channel: 0
    effects:
    • pulse:
      transition_length: 250ms
      update_interval: 250ms

The log:
INFO ESPHome 2023.10.6
INFO Reading configuration /config/esphome/m5stack-atom-echo-8a2098.yaml…
INFO Starting log output from m5stack-atom-echo-8a2098.local using esphome API
INFO Successfully connected to m5stack-atom-echo-8a2098.local
[18:28:52][I][app:102]: ESPHome version 2023.10.6 compiled on Nov 10 2023, 18:16:46
[18:28:52][I][app:104]: Project m5stack.atom-echo version 1.0
[18:28:52][C][wifi:546]: WiFi:
[18:28:52][C][wifi:382]: Local MAC: 64:B7:08:8A:20:98
[18:28:52][C][wifi:383]: SSID: [redacted]
[18:28:52][C][wifi:384]: IP Address: 10.174.183.140
[18:28:52][C][wifi:386]: BSSID: [redacted]
[18:28:52][C][wifi:387]: Hostname: ‘m5stack-atom-echo-8a2098’
[18:28:52][C][wifi:389]: Signal strength: -51 dB ▂▄▆█
[18:28:52][C][wifi:393]: Channel: 7
[18:28:52][C][wifi:394]: Subnet: 255.255.255.0
[18:28:52][C][wifi:395]: Gateway: 10.174.183.108
[18:28:52][C][wifi:396]: DNS1: 8.8.8.8
[18:28:52][C][wifi:397]: DNS2: 8.8.4.4
[18:28:53][C][logger:416]: Logger:
[18:28:53][C][logger:417]: Level: DEBUG
[18:28:53][C][logger:418]: Log Baud Rate: 115200
[18:28:53][C][logger:420]: Hardware UART: UART0
[18:28:53][C][esp32_rmt_led_strip:171]: ESP32 RMT LED Strip:
[18:28:53][C][esp32_rmt_led_strip:172]: Pin: 27
[18:28:53][C][esp32_rmt_led_strip:173]: Channel: 0
[18:28:53][C][esp32_rmt_led_strip:198]: RGB Order: GRB
[18:28:53][C][esp32_rmt_led_strip:199]: Max refresh rate: 0
[18:28:53][C][esp32_rmt_led_strip:200]: Number of LEDs: 1
[18:28:53][C][gpio.binary_sensor:015]: GPIO Binary Sensor ‘Button’
[18:28:53][C][gpio.binary_sensor:016]: Pin: GPIO39
[18:28:53][C][light:103]: Light ‘M5Stack Atom Echo 8z2098’
[18:28:53][C][light:105]: Default Transition Length: 0.0s
[18:28:53][C][light:106]: Gamma Correct: 2.80
[18:28:53][C][captive_portal:088]: Captive Portal:
[18:28:53][C][mdns:115]: mDNS:
[18:28:53][C][mdns:116]: Hostname: m5stack-atom-echo-8a2098
[18:28:53][C][ota:097]: Over-The-Air Updates:
[18:28:53][C][ota:098]: Address: m5stack-atom-echo-8a2098.local:3232
[18:28:53][C][api:139]: API Server:
[18:28:53][C][api:140]: Address: m5stack-atom-echo-8a2098.local:6053
[18:28:53][C][api:142]: Using noise encryption: YES
[18:28:53][C][improv_serial:032]: Improv Serial:
[18:28:53][C][audio:203]: Audio:
[18:28:53][C][audio:225]: External DAC channels: 1
[18:28:53][C][audio:226]: I2S DOUT Pin: 22
[18:29:25][D][media_player:059]: ‘M5Stack Atom Echo 8z2098’ - Setting
[18:29:25][D][media_player:066]: Media URL: http://homeassistant:8123/api/tts_proxy/eee0b150898a52492e40c392320ffd3a349922b7_en-us_-_google_translate.mp3
[18:29:25][W][component:214]: Component i2s_audio.media_player took a long time for an operation (0.58 s).
[18:29:25][W][component:215]: Components should block for at most 20-30ms.
[18:29:26][W][component:214]: Component i2s_audio.media_player took a long time for an operation (0.44 s).
[18:29:26][W][component:215]: Components should block for at most 20-30ms.

I’ve been doing a ton of digging on this and found the following:

  1. The default config for voice assistant on ESPHome doesn’t use media_player; it uses the speaker component instead
  2. There is currently a shortcoming where the ESPHome media_player cannot play raw audio files; this is a problem because piper currently returns raw audio files
    See: Wyoming integration returning incorrect URLs from piper · Issue #92969 · home-assistant/core · GitHub

Hopefully the PR for ESPHome that enables support for RAW will get merged in: Add support for raw files by robin-thoni · Pull Request #12 · esphome/ESP32-audioI2S · GitHub

But more hopefully than that is that the fix to the HA voice assistant integration makes it way to a release version:

Although, since it’s labeled as a breaking change, I’m going to guess the wait for that is going to be a little while.