Play local file from HA to Google Home

Hello community, I search a lot here in the forum but didn’t find anything. I would like to play a local mp3 file from my Raspbian HA 0.67 to Google Home Device. This is the code I used:

  - service: media_player.play_media 
    data_template:                 
      entity_id: media_player.camera_da_pranzo            
#      media_content_id: https://dl.dropboxusercontent.com/s/pvjq2i9dfghm202r/aria.mp3?dl=0 
      media_content_id: /local/aria.mp3 
      media_content_type: 'audio/mp3' 

The dropbox method works perfect, but can’t realize how to play local file. I stored the mp3 under:
/home/homeassistant/.homeassistant/www

root@raspberrypi:/home/homeassistant/.homeassistant# ll www
-rwxrwxrwx 1 homeassistant homeassistant 2426490 Apr 29 10:01 aria.mp3

I also tried on browser:
https://mydomain.duckdns.org/local/aria.mp3
But I got: 404: Not Found

Obliviously the https://mydomain.duckdns.org address works perfect.

Could someone drive me to a solution? Thank you.

OK, I restarted HA and now I’m able to reach and play the mp3 using the http link:

https://mydomain.duckdns.org/local/aria.mp3

But still don’t get audio on Google Home with:

  media_content_id: /local/aria.mp3 
  media_content_type: 'audio/mp3'

or

  media_content_id: https://mydomain.duckdns.org/local/aria.mp3
  media_content_type: 'audio/mp3'

I don’t use the duckdns service as I keep all my stuff local. Try changing the url you’re using to be your local IP and not HTTPS. I also don’t see your port number are you answering on 443 or 80 and using a proxy?

Like I said, I always kept mine local.

Mine refuses to play unless it’s the “public” URL

Try removing the first slash in front of “local”. I seem to remember that when called from within HA it is a “relative” link.

Well, after a new restart, now it’s finally working, and this is the final configuration I used:

  - service: media_player.play_media 
    data_template:                 
      entity_id: media_player.camera_da_pranzo            
      media_content_id: https://mydomain.duckdns.org/local/aria.mp3
      media_content_type: 'audio/mp3' 

Most probably HA needs to restart not only to read the new configuration but also to read the mp3 into the www directory. My mp3 is under /home/homeassistant/.homeassistant/www directory and I need to create www one and assign permission and owner both to www and mp3 file (homeassistant as group and user with permission 755).

2 Likes

A restart is a definite for it to know about the configuration change.

I am looking for the same thing. Did you ever get it to work, locally?

@Lucas_Rey
how long is the delay before your Google Home starts playing sound?

Something has changed since 0.109- before my doorbell played its mp3 at full length, now it simply plays GA “dong” and a fraction of original .mp3 and then something like GA cancel “ding”?
Automation action was never changed for 3 years…
Something like that:

entity_id: media_player.my_GA
media_content_id: 'http:/my_ip:8123/local/media/doorbell_chime.mp3'
media_content_type: music

No ideas anymore…
Best, JR

Sorry guys- figured it out: I use a Raspberry PI4 based android dashboard which uses the same Google Mini for sound output via BT- and action notifies it too- so this cancels GA playback :frowning: Rewriting now… :slight_smile: