Playing Random MP3 from Folder

I have having a tough time getting this to work.
I used the folder sensor to list the items in the folder.

This is my code to play media.

action: media_player.play_media
metadata: {}
data:
  media_content_id: {{state_attr('sensor.wow', 'file_list') | random }}
  media_content_type: audio/mpeg
target:
  entity_id: media_player.nesthubmax23e0

The output looks like this:

action: media_player.play_media
metadata: {}
data:
  media_content_id: /media/Wow/88_WeWow_on_the_Weekend_(7-27-24).mp3
  media_content_type: audio/mpeg
target:
  entity_id: media_player.nesthubmax23e0

I suspect my media content id path is incorrect.

Any ideas?

Hello oron_enthusiast,

My homeassistant: key in configuration.yaml looks like this…

homeassistant:
  media_dirs:
    local: /media

When I store my MP3’s, I store them in
/media/mp3/file.mp3

When I pull the files for use, I call them as:
media-source://media_source/local/mp3/Dryer.mp3

You didn’t ask, but I also always use content type
audio/mp3

I also have other folders next to the mp3 folder, and other paths listed, but for mp3’s that’s what I do.
HA Config

Seems to work just fine for me. Currently my speakers are Google Home devices.

Thanks for sharing.

I think this will work if I was pulling a specific mp3 file.

With my setup, I am trying to play a random mp3 from my mp3 folder.

Changing the content type didn’t fix it either.