Solved - Play an MP3 sound using Google Home for doorbell (Was a typo)

Hey,

I have been at this for the last few hours, googling, and trying many variations of the automation, based on many of the suggestions on this forum.

But I cant seem to get the simplest to work :frowning:

Google already works fine, and from my normal dashboard, I can turn on a device,and type the TTS stuff, and it all works. So that works.

I want to have an automation based on a sensor, but that got working, and that is tested by triggering a light, no problem there either.

But I cant seem to get my Google Home’s to play the doorbell.mp3 sound.

I have tried the path as /local/doorbell.mp3, same problem
If I use the path in a browser http://192.168.10.2:8123/local/doorbell.mp3 it also works.

I have tried to add another action step to “turn on” the media player, and I can hear them doing the “boink” sound, as they indicate that they are ready…

But what am I missing here ? It should have been so simple :slight_smile:

2 Likes

It should be entity_id: not entity:
Also when did you create the www folder in your installation? Have you restarted HA after creating it?
Here is my automation:

  - service: media_player.play_media
    data:
      entity_id: media_player.google_home_minis
      media_content_id: 'http://192.168.0.24:8123/local/Doorbell_Tubular_2.mp3'
      media_content_type: 'audio/mp3'
2 Likes

DOOOHH !!! It was that entity_id and not entity.

Thank you for seeing what my eyes failed to see :slight_smile:

2 Likes

I’m a noob. Please help.

I followed the notes above.
Created www folder in /config/
Restarted Core

Created new automation in the UI. Saved. Clicked “run actions”. Sometimes the Home speaker goes boink, so I know something is happening.
But the file never plays.
If I copy the content_id’s URL into a browser page, the track will play.
What’s wrong?

service: media_player.play_media
target:
device_id: xxxxxxxxxxxxxxx_device_ID
data:
media_content_id: http://homeassistant.local:8123/local/xxxxxxxxxx.mp3
media_content_type: audio/mp3

Can you format your code correctly? I can’t see if there are indentation errors

Sorry, trying again. I tried putting single backticks around it but it doesn’t maintain the format… also tried “preformattted text” which inserts 3 backticks – that didn’t work either.

service: media_player.play_media
target:
  device_id: 40exxxxxxxxxxxxxxxxxxxxxxxxd9a
data:
  media_content_id: http://homeassistant.local:8123/local/wxxxxxxxxxxxxxxxxxxg.mp3
  media_content_type: audio/mp3

can you test with your HA IP address instead of homeassistant.local? Wondering if you have dns / domian retrieval issues

That worked.
IDK why, but it did. Now I have to wonder about my DNS/etc.

Thanks!

I’m not able to get the sound to play with my automation, but if I go to the Media Browser and play the sounds from “all.speakers”, it works perfectly. When I try to replicate the behaviour in an automation, I just get the “boink” on sound from the Google speakers, but the audio doesn’t play. My log shows that the speakers have been changed to “idle”.

When I play the audio directly from the Media Browser, it shows “playing”, then changed to “idle” in the logs.

If I enter the URL for the target sound, it gives me an ERR_SSL_PROTOCOL_ERROR. Maybe I’m not entering it properly? I’ve tried with http and https.

Here is my automation:

service: media_player.play_media
target:
  entity_id:
    - media_player.all_speakers
data:
  media_content_id: https://xxx.xxx.x.xxx:8123/local/Doorbell.mp3
  media_content_type: audio/mp3

Solved: After digging around, I found that I have to change the content id to: ‘media-source://media_source/local/filename.mp3’. I also changed content type to music.

service: media_player.play_media
    target:
      entity_id:
        - media_player.all_speakers
    data:
      media_content_id: media-source://media_source/local/Doorbell.mp3
      media_content_type: music
2 Likes

does anyone know how to make this work with Sonos Speakers? I have this working on a google nest hub but cant get the sonos to play …

service: media_player.play_media
target:
  entity_id: media_player.office_nest
data:
  media_content_id: "http://192.168.1.229:8123/local/audio_files/Ring - Westminster_Quarters.mp3"
  media_content_type: audio/mp3

For Sonos the file that worked for me was with 44100Hz bit rate, high bit rate did not work. I also placed a delay of 4sec for a 4 sec doorbell ring mp3 file, to avoid chopping of audio by next Sonos command. Files was placed under www folder:

  - service: media_player.play_media
    target:
      entity_id: media_player.living_room
    data:
      media_content_id: "http://xxx.xxx.0.241:8123/local/doorbell.mp3"
      media_content_type: "music"
  - delay: '00:00:04'

This worked for me too. Thanks.