[SOLVED] Struggling to play media to Google Home for doorbell

Hi there,
I am struggling to play an audio file in my www folder through my Google Home. I am new to HA. Is there any configuration that I need to write to get the media to work? (I don’t currently have anything around media in my config folder.

When I run the code, I get the Google Home turning on through a beep, but the media file is not playing.

- alias: Doorbell Ring

  trigger:

    platform: state

    entity_id: sensor.doorbell_action

    to: 'on'

  condition:

    condition: time

    after: "06:30:00"

    before: "22:00:00"

  action:

    service: media_player.play_media

    data:

      entity_id: media_player.google_home

      media_content_id: http://homeassistant.local/:8123/config/www/media/doorbell-1.mp3

      media_content_type: audio/mp3

This is my current code. I don’t know what’s wrong with it. I am using an Ikea shortcut button as a doorbell. Is my trace wrong? I have looked at many other forum posts as well as HA documentation but nothing seems to work.

My external address does not work - neither does

media-source://media_source/local/doorbell-1.mp3

This is my file trace.
image

Any help would be greatly appreciated. Thanks!

Welcome :slightly_smiling_face:
This works for me with the media file directly under /config/www/

trigger:
  - platform: state
    entity_id:
      - switch.natt_44
    to: 'off'
condition:
  - condition: time
    after: '06:30:00'
    before: '22:00:00'
action:
  - service: media_player.play_media
    data:
      media_content_id: /local/Bell.mp3
      media_content_type: music
    target:
      entity_id: media_player.nesthubce17

No, still nothing working for me. What is in your configuration file? Anything around media?

What is your config now? What does the automation debug say?

The only thing in my config is

media_source:

The automation debug didn’t say that anything was wrong, or was I just misreading?
Do I need to add config for Google home or downloader?

You posted your code in the first post.

You have changed your code.

Post the changed code.

This is my changed code.

- id: Doorbell_please_ring

  alias: Doorbell Ring

  trigger:

  - platform: state

    entity_id:

      - sensor.doorbell_action

    to: 'on'

  condition:

    - condition: time

      after: '06:30:00'

      before: '22:00:00'

  action:

    - service: media_player.play_media

      data:

        media_content_id: /local/Bell.mp3

        media_content_type: music

      target:

        entity_id: media_player.google_home

One thing: even if I play my media manually through the media browser, I get this error.

Have you done that? Open your Home Assistant instance and manage your systems network configuration.

Yes, but I don’t know if I have done it correctly. Since I have configured http in my config, it is saying that I need to have an internal URL that is set to a domain and covered by the certificate.
Any thoughts?

I got it to work with this code by adding an external URL to the configuration file. All you need to do is add external URLs and media directories to allow access to the media file.

- id: Doorbell_please_ring

  alias: Doorbell Ring

  trigger:

  - platform: state

    entity_id:

      - sensor.doorbell_action

    to: 'on'

  condition:

    - condition: time

      after: '06:30:00'

      before: '22:00:00'

  action:

    - service: media_player.play_media

      target:

        entity_id: media_player.google_home

      data:

        media_content_type: audio/mp3

        #media_content_id: "https://www.soundjay.com/door/sounds/doorbell-1.mp3"

        media_content_id: /local/Bell.mp3

And the added configuration:

allowlist_external_urls:

    - "https://www.soundjay.com/door/sounds/doorbell-1.mp3"

  media_dirs:

    media: "/config/www"