How to play mp3 through google home?

I have tried this but there is nothing after the turn_on-beep in the speakers.
Used samba to put the mp3 file into the mp3 folder.

script:
    play_song:
        sequence:
          - service: media_player.turn_on
            data:
              entity_id: media_player.all
          - service: media_player.volume_set
            data_template:
              entity_id: media_player.all
              volume_level: 0.5
          - service: media_player.play_media
            data_template:
              entity_id: media_player.all
              media_content_id: '/config/mp3/dawn-chorus.mp3'
              media_content_type: music

I think you need to name the file /local/mp3/your_file.mp3. You need to create a folder called www in the root of HA, and place the files there, that is where the local folder looks for things such as mp3’s and JPG’s.

Let me know if that works for you as I’m looking at doing something similar myself.

Hi I’m also trying to do this. My daughter has sleep music to go to sleep , so I would like to say ok Google ‘Goodnight’ then play a local or hosted MP3.

Under Delveloper services this is working But how do I get a button and google to turn it on?

{
  "entity_id": "media_player.googlehome7576",
  "media_content_id": "http://XXXX.com.au/Peaceful.mp3",
  "media_content_type": "audio/mp3"
}

Add the service call as a script:

Also curious, how can I make Google Assistant execute that script?
I have exposed the scripts to HA Cloud.

I have exposed scenes towards GA that run scripts.
Maybe that will work with scripts only…

And i activate them by “hey google activate scenename”

I am trying to play an mp3 file on a google home speaker via services.

have the following under developer tools / services / Service media_player.media_play:

{
“entity_id”: “media_player.living_room_speaker”,
“media_content_id”: “http://xxx.xxx.xxx.xxx:8123/local/Fanfare-sound.mp3”,
“media_content_type”: “audio/mp3”
}

This error message is displayed on call service:

Failed to call service media_player.media_play extra keys not allowed @ data[‘media_content_id’]

I can play the audio via the browser with the url loaded. Can anyone point me in the right direction? Why is ‘media_content_id’ not allowed?

Fixed it, the service is play_media, not media_play!

1 Like

How did you get the mp3 file shared and accessible through the Home Assistant local address?

Everything placed in the www folder (which is adressed as “local”) is exposed by the HA webserver, both internally and externally, so use that folder with caution.

If you only want to expose files locally for playing mp3’s on a local device, you could run a python simplehttpserver, have a look here regarding this. https://stackabuse.com/serving-files-with-pythons-simplehttpserver-module/

I created the www folder within the config folder but I still cannot access the files inside that folder using the url http://my-local-ip:8123/local/audio.mp3, I may be doing something wrong but I don’t know what.

Found the issue, I just needed to restart HA, thank you very much

I just uploaded it to the www folder within the config folder. Can’t remember if it was there or I created it. I connected to the config folder via the samba share add-on. Hope that helps.

Sorry to open up, but what is the exact path to store your mp3? I still can’t get to get it to work.
I am using a VM on my raspberry pi and tried already make a map ‘www’
into the svr/homeassistent path but i can seem to get it to work.
I also red somewhere the config path i tired but i seem to fail

This is a script I use to play a sound file. It just asks siri “what is the weather like today” with siri responding by reading the weather.

The mp3 file is located in config/www/audio

1554696403234':
  alias: Read Weather
  sequence:
  - data:
      entity_id: media_player.living_room_speaker
      media_content_id: http://<ip address>:8123/local/audio/weather_en_google.mp3
      media_content_type: audio/mp3
    service: media_player.play_media

Hope that helps.

2 Likes