How to play sound files as alarms and notifications via Raspberry Pi 4 audio socket?

I have been able to play sounds through the Rapberri Pi 4 audio output (jack 3,5mm). This is what I did:

  1. Add the following repository in Addos: GitHub - Poeschl/Hassio-Addons: The repository for my Home Assistant Supervisor Add-ons.

  2. Install MPD addon. Go to Configure and select Output as Bulti-In Audio Stereo:

  1. Include the following code in your “configuration.yaml”
media_player:
  - platform: mpd
    host: "the IP of your local host"
  1. Run the Addon.

  2. Save your MP3 files in the folder /media/

  3. Create a Script like the following:

alias: Doorbell
sequence:
  - service: media_player.play_media
    data:
      media_content_id: media-source://media_source/local/doorbell-1.mp3
      media_content_type: audio
    target:
      entity_id: media_player.mpd
mode: restart

Note: The folder /local/ of the script is equivalent to the /media/ folder.

3 Likes