Unable to play local mp3 to Google Home

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.

This works for me to play a local .mp3 on Google Home Mini from both my old Hassio RPi and HA on docker & Ubuntu on a PC. This is the GUI switch defined in configuration.yaml:

# Virtual inputs that execute scripts:
input_boolean:
  play_gloria:
    name: "Play Gloria!"
    initial: off
    icon: mdi:microphone-variant

This is the automation that sees the switch turn on:

- id: gloria  # When the GUI switch goes On, execute a script to play an audio file on Google speaker.
  alias: Gloria
  initial_state: true
  trigger:
  - entity_id: input_boolean.play_gloria
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - service: script.ghm_gloria

This is the script that plays the song:

ghm_gloria:  # Play an audio file through Google Home Mini speaker, then turn off the GUI switch:
  alias: Gloria!
  sequence:
    - service: media_player.play_media
      data:
        entity_id: media_player.basement_speaker
        media_content_id: http://192.168.1.116:8123/local/audio/Gloria.mp3
        media_content_type: audio/mp3
    - service: input_boolean.turn_off
      data:
        entity_id: input_boolean.play_gloria

This is the directory structure under my Home Assistant config folder, as seen through the NFS client on my laptop:

I don’t know if it matters, but I don’t currently have an http: section defined in my configuration.yaml file.

1 Like

I finally got around to testing this again today and it works just fine if I drop the URL into a script. You can use either your local or your remote URL, both work.

  test_play_file:
    sequence:
      - service: media_player.volume_set
        data:
          entity_id:
            - media_player.lounge_home
          volume_level: '0.70'
      - service: media_player.play_media
        data_template:
           entity_id:
             - media_player.lounge_home
           # media_content_id: http://localhassioip:8123/local/audio/doorbell_classic.mp3
           media_content_id: https://remotehassioip/local/audio/doorbell_classic.mp3
           media_content_type: 'audio/mp3'
1 Like

I could not make it play with local mp3, i use hassio. i use https address both local and remote

I’ve been struggling with this too. Google Home uses hardcoded DNS servers (it’s own 8.8.8.8/8.8.4.4) and it ignores DNS servers provided by DHCP. Google Home also only accepts secure HTTP (https) urls that can be resolved using Google DNS servers. Internal IP-addresses for url’s will also be ignored, as you cannot request a publicly accepted certificate for a (local) IP-address. So if you’re using split DNS (running the same domain internally as externally), there are 2 work-around:

  1. Block the Google Home in your firewall for making external DNS requests (TCP port 53). That way it is forced to use your local DNS server (provided by DHCP) and it will play local files provided via a secure http url
  2. Enable your router for network ‘hair pin’ or ‘loop back’, that allows internal devices to access internal resources via the external interface.

Hope this helps.

Not true at all.

Also not true.

Well, then I guess that a lot has changed in the last 5 months :wink: Because back then, it didn’t work. However, my Sonos One (with Google Assistant) is a lot less fuzzy. Perhaps you can explain why you think it’s not true?

I am able to trigger my Google Homes to play locally hosted MP3s from my Home Assistant install and it’s only using HTTP (non-ssl) via it’s internal IP address (192.168.1.xxx).

I second @firstof9, and my complete config showing local play is above, in this thread.

The problem is that when you’re using HTTPS, you almost certainly don’t have a certificate for your IP address. You have that certificate for your domain name, which you’re not using if you’re trying to use your internal IP. This can’t work, and it’s why the Google Home doesn’t like that URL. It has nothing to do with names being resolved.

The only real solution I’ve found for this that ticks all the boxes I need is to NOT configure HA for HTTPS at all, and instead set up a reverse proxy like NGINX to handle HTTPS and forward the requests to HA over just plain old HTTP. Then you can use a URL like http://192.168.1.34/local/file.mp3, and it works just fine when you try to cast it.

2 Likes

You can start by reading up on these threads in which this topic is discussed:

Can confirm, this is exactly what I do. SSL sits on the proxy side only, and LAN access stays unencrypted.

1 Like