Problem with media player for response output

Hi,

I installed a few atom echo’s according to the “$13 instructions” and that works as expected. But the atom echo doesn’t have a very nice speaker and is sometimes hard to understand.

So I followed the instructions found here: ESPHome: Voice Assistant with External Speaker Integration

I have tried a few things, and the part that I can’t get to work is:

  on_tts_end:
    - homeassistant.service:
        service: switch.toggle
        data:
          entity_id: switch.shelly1_01
    - homeassistant.service:
        service: media-player.play_media
        data:
          entity_id: media_player.sonos_move
          media_content_id: "http://192.168.1.18/test_piper.wav"
          media_content_type: music
          announce: 'true'

As you can see in the snippet above, I added another service call (the first) to switch a light, and this is working as expected. So the automation on_tts_end is executed.
The second service call is the one I need, but this doesn’t produce any audio.

In the original solution the media_content_id has a lambda function, but I replaced it with a static id just to eliminate any lambda errors. I also needed to put quotes around the ‘true’ value of announce, because without the quotes tje code compilation fails with:

Must be string, got <class ‘bool’>. did you forget putting quotes around the value?.

I also tested without the announce: line , but with the same results

If I test the following in the dev tools => services:

service: media_player.play_media
target:
  entity_id: media_player.sonos_move
data:
  media_content_id: http://192.168.1.18/test_piper.wav
  media_content_type: music
  announce: true

This works fine.
Before you ask, I installed and updated everything:
HAOS 12.2, Core 2024.5.2, Supervisor 2024.04.4, Frontend 20240501.1
ESPHome 2024.4.2

I really do not understand what I am doing wrong, any help will be greatly appreciated!

Marcel

I did some more digging. First I made a packet capture from the atom to the HA server. I did see traffic, but it appears to be encrypted. No luck there.

Then I found a reference to debugging integrations, so I tried that. Under Settings → Integrations → ESPhome I enabled debugging, and tested again. The relevant part of the result is below (I changed the config so the media player action is first, the light is second, just to be sure that the order indeed is irrelevant):

2024-05-07 19:47:59.554 DEBUG (MainThread) [aioesphomeapi.connection] m5stack-atom-echo-4 @ 192.168.6.17: Got message of type LightStateResponse: key: 1589573588
state: true
brightness: 1
color_mode: 35
color_brightness: 1
blue: 1
white: 1
cold_white: 1
warm_white: 1
effect: "None"

2024-05-07 19:47:59.589 DEBUG (MainThread) [aioesphomeapi.connection] m5stack-atom-echo-4 @ 192.168.6.17: Got message of type HomeassistantServiceResponse: service: "media-player.play_media"
data {
  key: "entity_id"
  value: "media_player.sonos_move"
}
data {
  key: "media_content_id"
  value: "http://192.168.1.18/test_piper.wav"
}
data {
  key: "media_content_type"
  value: "music"
}
data {
  key: "announce"
  value: "true"
}

2024-05-07 19:47:59.589 DEBUG (MainThread) [aioesphomeapi.connection] m5stack-atom-echo-4 @ 192.168.6.17: Got message of type HomeassistantServiceResponse: service: "switch.toggle"
data {
  key: "entity_id"
  value: "switch.shelly1_01"
}

2024-05-07 19:47:59.644 DEBUG (MainThread) [homeassistant.components.esphome.voice_assistant] Sending 72160 bytes of audio

The first light output is the LED in the Atom Echo itself.
Next is the audio (which I want, but doesn’t work!)
The last one is a light on the shelly1_01 which is toggling as expected.

Perhaps one of the more experienced people on this forum can see in these log lines what the problem is. Or give me some tips where to look for more relevant information.

Thanks!

Marcel

Found it! media_player is with an underscore, not with a dash!