Unable to play local mp3 to Google Home

I managed to play local mp3 sounds on my chromecast this is what I have done:
https://mydomain.duckdns.org/local/mp3/HappyBirthday.mp3 for automation I used this:

  • alias: Play Happy Birthday
    trigger:
    platform: state
    entity_id: group.family
    to: home
    action:
    service: media_player.play_media
    data:
    entity_id: media_player.living_room_speaker
    media_content_id: https://mydomain.duckdns.org/local/mp3/HappyBirthday.mp3
    media_content_type: audio/mp4

I am using Hassbian, but I believe it will work on Hassio too. Just put the files under the www directory in Home Assistant.

This isn’t ‘local’. This is using your PUBLIC URL to play the file. It has to be a ‘public’ URL for it to work.

Sorry, my bad!

To play a local MP3 file on my local Google Home Assistant Mini, the procedure that finally worked for me was:

Install HassIO onto Raspberry Pi. Install Add-On, Samba Share.
From laptop or PC, map to Samba share, config.
From laptop or PC, create subdirectory under config named: www
Then create subdirectory under config/www named: audio
Copy the mp3 file to /config/www/audio
Restart HassIO. This is required to make HassIO start sharing the new folders locally via http.
After HassIO has restarted, from laptop or PC, browse to http://Local_IP_Address_of_HA:8123/local/audio/YourSong.mp3
The browser should launch the audio file using whatever your browser has configured to play MP3s. That proves the changes above were effective.

Now configure HassIO to play the file.
I’m using an automation to play mine at 7PM every day, like this (in automations.yaml):

- id: 'PlayMySong'
  alias: PlayMySong
  trigger:
  - at: '19:00:00'
    platform: time
  action:
  - service: media_player.play_media
    data:
      entity_id: media_player.google_mini
      media_content_id: http://192.168.1.2:8123/local/audio/mysong.mp3
      media_content_type: 'audio/mp3'
6 Likes

Hey great. Here is what I use google home mini playing alarm sound when motion detected:

  - alias: "Dafang Living Room motion detection warn via Line"
    trigger:
    - entity_id: binary_sensor.dafang_motion_sensor
      from: 'off'
      platform: state
      to: 'on'
    condition:
     - condition: time
       after: '00:00:01'
       before: '23:59:00'
    #   after: '00:02:01'
    #   before: '00:05:30'
    action:
      - service: shell_command.dafang_living_room
      - service: light.turn_on
        data:
          entity_id: light.mezzanine_lamp
          effect: red_strobe
      - service: media_player.turn_on
        data:
          entity_id: media_player.google_home
      - service: media_player.volume_set
        data:
          entity_id: media_player.google_home
          volume_level: .8
      - delay: '00:00:05'
      - service: media_player.play_media
        data:
          entity_id: media_player.google_home
          media_content_id: http://192.168.2.14/hassio/PoliceSirenLoopSound.mp3
          media_content_type: 'audio/mp3'

What I don’t know is to make it repeats playing the siren sound.

I haven’t tried to repeat playing a sound from Home Assistant through my Google Home Mini, but maybe one of these articles would help you do that?

1 Like

Thanks for your suggestion. I will try those solutions. In the meantime, I use Audacity software to repeat the siren sound from 30 sec to 5 min and save as a long version siren mp3 file. That would be enough to scare the thief :grinning:

I’m trying to test this also but having no luck on the services panel.

{
"entity_id": "media_player.kitchen_home", 
"media_content_id": "http://ipofhassio:8123/local/audio/doorbell1.mp3", 
"media_content_type": "audio/mp3"
}

That produces the error extra keys not allowed @ data['media_content_id'] even though popping that URL into my browser plays the file. Anyone see what I’m doing wrong?

This is one of the action when motion was detected. It will turn light on as strobe light, google home on, increase volume, play my recorded siren sound (last 5 minutes), then decrease volume.

    action:
      - service: shell_command.dafang_living_room
      - service: light.turn_on
        data:
          entity_id: light.mezzanine_lamp
          effect: custom
      - service: media_player.turn_on
        data:
          entity_id: media_player.google_home
      - service: media_player.volume_set
        data:
          entity_id: media_player.google_home
          volume_level: .9
      - delay: '00:00:05'
      - service: media_player.play_media
        data:
          entity_id: media_player.google_home
          media_content_id: http://192.168.2.14/hassio/PoliceSirenLoopSound5min.mp3
          media_content_type: 'audio/mp3'
      - delay: '00:06:00'
      - service: media_player.volume_set
        data:
          entity_id: media_player.google_home
          volume_level: .5

Are you invoking the service, media_player.play_media ?

I can’t get the following to work and don’t know why. I get the link sound when the Google Home device is about to play something, but nothing else

      - service: media_player.play_media
        data:
          entity_id: media_player.lounge_mini
          media_content_id: http://192.168.0.14:8123/local/sounds/airport.mp3
          media_content_type: 'audio/mp3'

Yes, I surely am.

I’ve never been able to get it to play a LOCAL file, because Google Home uses HTTPS, and needs a publicly accessible site to stream from.

Unless Google has changed something in the last couple of days, my Google Home Mini plays local MP3 files right off my HassIO HA, using http and a local IP address.

I haven’t been able to get that to work for 2 years…

I use the following and it plays my MP3 just fine on the Google Homes:

  - service: media_player.play_media
    data:
      entity_id:
      - media_player.living_room_home
      - media_player.master_bedroom_home
      - media_player.receiver
      media_content_id: "http://192.168.1.203:8123/local/alarm.mp3"
      media_content_type: audio/mp3

Every time I have tried with a local http address, nothing comes out of my Google Home. As soon as I change it to my publicly accessible URL it works.

Similar links are generated when you use the Google TTS for the google homes, so it should work fine for you if you’ve used the TTS before.

I’ll test & post the relevant config later.

1 Like

I haven’t messed with it in a while, because I got gig fiber internet, so even using my reverse proxy outside my network, the latency isn’t even a concern any more.