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

Hi
I’m a total beginner with home assistant and I wonder what would be the most straight forward way to do the following:

Use case:
I live in a top floor apartment with roof windows. When I leave my apartment in the morning and one of the roof windows is still open I want to get an audio notification through a speaker near the apartment door.
The notification must be immediate. It won’t help if it plays when I’m already on my way to the car.
I have no network connected audio system like Sonos.
Speech synthesis is not necessary. Being able to play specific wave files for specific notifications would be enough.

Preferred solution:
I want to connect a cheap powered speaker to the audio output of the Raspberry Pi 4 that runs home assistant and use it for all kinds of audio notifications. I would upload wave or mp3 files to the Raspberry Pie and specify which file to play in my automations.

It already existed:
I have searched for existing solutions and I know that there have been a couple of working ones in the past but none of them seem work with the current version.

How would you archieve the described functionality?

Best Regards
Zebi

I believe the way to do this now is by using the VLC addon:

Thanks. Is it no more correct that I first need to install a sound service like pulse audio to enable local audio output?

I have now installed the Add-On and the integration. When I play a short sound file from the media page and select VLC_TELNET as target the sound is played but it is interrupted several times.

Meanwhile I noticed that VLC is adding every played sound file to an evergrowing playlist. This is not what I want.
I need a simple sound output. Is there really no way to do this in Home Assistant?

I was under the impression that VLC worked now. There is a simple way that I use but it is not by connecting a speaker to home assistant.

I have looked into ESPHome and it seemed that they had just started developing an audio integration. I’ll have a second look.

In the meantime I have found more possible ways to get local audio running:

Markus Pöschl maintains currently working versions of MPD and Mopidy which both are said to enable local audio output.

An even simpler approach seams to be “local audio player” by Dingedan.

I will try these options, too, but since these are community provided add-ons like all the other local sound output solutions that don’t work anymore, I fear that they will also stop working after a couple of updates.

Thanks
Zebi

I found a solution! :smiley:

The MPD and Mopidy approaches had the same problem as VLC: They can’t just play a file. These media players all require a playlist. Playing a file means:

  1. Clear the playlist
  2. Add the file to the playlist
  3. Play the playlist
  4. Clear the playlist again

Dingedan had the much better idea by harnessing the power of SoX.

Unfortunately Home Assistant became incompatible to his add-on about a year ago. At this time Manzari made a fork which worked for about 6 months until Home Assistant became incompatible to this version, too. Now I decided to continue this legacy by forking Dingedan’s version and adapting it to the current Home Assistant version which is

  • Home Assistant Core 2022.6.7
  • Home Assistant Supervisor 2022.05.3
  • Home Assistant OS 8.2"

This is the currently working solution for playing sounds and signals through the local audio output of Raspberry Pi 4:

Zebi / Triangulix