Play audio (local MP3 file) to a media_player

This version doesn’t work either:

service: media_player.play_media
data:
  media_content_id: >-
    http:/192.168.178.121:8123/local/media/audio/Achtung-Im-Bad-oder-WC-Fenster.mp3
  media_content_type: music
target:
  entity_id: media_player.wohnzimmer_sonos

Try accessing the url from a browser and see what happens

Try accessing the url from a browser and see what happens

I’m getting an 401-Error:

401: Unauthorized

It looks like you’re missing the second “/” after http:.

  media_content_id: 'http://192.168.178.121:8123/media/audio/Achtung-Im-Bad-oder-WC-Fenster.mp3'
  media_content_type: audio/mp3

Also, I believe there’s an issue (bug) with accessing the default media folder via URL. I ended up creating a folder named sounds under root/config/www and reference it like this:

media_content_id: 'http://192.168.0.115:8123/local/sounds/rocketlaunch.mp3'
3 Likes

You made my day. Thank you very much, with the new location under /config/www/ ist’s working like a charm.

To access the default media folder you can try:

media_content_id: /media/local/sounds/rocketlaunch.mp3

Assuming you have a folder named “sounds” in your default media folder.

CFC

2 Likes

Ciao a tutti! Vi scrivo in Italiano perchè col traduttore automatico farei di peggio. :smiley:

Per riprodurre i file locali su Hassio usando l’uscita jack 3,5 mm ho usato il seguente procedimento:

01 - Installare l’Add-On MDP Player caricando il seguente repository:https://github.com/Poeschl/Hassio-Addons

02 - Mettere spunta su “Mostra nella barra laterale”. La configurazione di MPD l’ho lasciata di default.

03 - su configuration.yaml aggiungere il seguente testo:

media_player:
platform: mpd
host: 127.0.0.1
port: 6600

Riavviate Home Assistant.

04 - Per l’esempio parlo di un file mp3 chiamato “Doorbell.mp3” però credo sia uguale anche per altre estensioni.
Usando l’estensione “Samba” posizionare i file nella cartella \HOMEASSISTANT\media\mpd\media\Doorbell.mp3

05 - Sull’interfaccia web di MDP andare su “settings/update DB/save” e vi verrà aggiornata la lista dei file disponibili.

06 - Per usare i file mp3 sulle automazioni io ho usato il seguente testo:

service: media_player.play_media
target:
entity_id: media_player.mpd
data:
media_content_id: Doorbell.mp3
media_content_type: audio/mp3

07 - Devo ancora capire come poter agire sul volume, comunque così è più che utilizzabile.

08 - Buon divertimento!

Hi. Is there anyway to do this if I have HA running as a VM in Virtualbox?

I have mine running in VMWare Fusion. I assume it’s just the same.
Use the add-on Samba Share to expose your Home Assistant files on your local network.
That’s the easiest way to get at the files. Visual Studio Code even allows you to drag and drop tiles to your directories.

Hi. I have installed Hassio on Raspi.
I want to do something simple. I want to send an mp3 audio file to Google mini when an event occurs. The audio file is stored under the media folder. Now if I launch the service from Develeper Tools the file is played, but it doesn’t work from the automation. From Google mini, only the Google assistant type sound is lacking. Anyone have an idea?


This is my automation:

- id: gg_food_waste  
  alias: gg_food_waste
  trigger:
    platform: time
    at: '17:05:00'
  condition:
    condition: time
    weekday:
      - tue
      - thu
      - sat
  action:
  - data:
      entity_id: media_player.gm
      volume_level: '0.7'
    service: media_player.volume_set
  - data:
      entity_id: media_player.gm
      media_content_id: /media/local/messaggi/Conf_Umido.mp3
      media_content_type: audio/mp3
    service: media_player.play_media  

Anything in logs?

Nothing. Unluckily

Are you sure, this is the correct path?

In my vision the path starts with /local/…

hi.
Yes also because it works if I call the service from the dev panel.
I wait for the night to pass and reflect with a fresh mind.
Thanks

any updates on this?

Just after uploading my mp3 file in multimedia/local media, i try this in the “content id” field and it works !

media-source://media_source/local/music.mp3

Placed mp3 in the “local” folder here:

/config/www/sounds/doorbell-1.mp3

called service as follows:

service: media_player.play_media
data:
  media_content_id: /local/sounds/doorbell-1.mp3
  media_content_type: music
target:
  entity_id: media_player.dining_room

Please note, using nabu casa.
If using duckdns use the full url
e.g.

service: media_player.play_media
data:
  media_content_id: https://something.duckdns.org/local/sounds/doorbell-1.mp3
  media_content_type: music
target:
  entity_id: media_player.dining_room

:

1 Like

Hi all.

I recently got a ESP Muse Luxe. I’ve set it all up in Home-Assistant and it’s running ok. I’m struggling in getting the commands in Home-Assistant to play mp3 from the ESP Muse SC CARD.
Is it possible? Any one got it playing from the Muse local sc card?
All the help is very appreciated.

Thanks!

Does the entity appear in home assistant? E.g media_player.esp_muse or whatever name you gave it.
If so, you can try play a sound (mp3 for example) through the services section of developer tools. I’m not familiar with that device but ensure its not muted as well.

edit configuration.yaml and enter the following lines
homeassistant:
allowlist_external_dirs:

  • /media
    media_dirs:
    local: /media

I created an automation to play the file. you may be able to use button
action:

service: media_player.play_media
target:
entity_id: media_player.mpd
data:
media_content_type: audio/mp3
media_content_id: media-source://media_source/local/Dumps/Songs/Bhajans/Hanuman Chalisa/Hanuman Chalisa - Mahendra Kapoor.mp3
mode: single