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?
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 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.
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:
Clear the playlist
Add the file to the playlist
Play the playlist
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:
I’m still using the old method with “SSH & Web Terminal” version 9.1.1 by Frenck (Franck Nijhof) witch uses paplay of pulse audio by passing commands (STDIN).
My automations just need to pass the audiofilename to play (.wav files) to the script below
Still working actually with latest HA version but i can not upgrade ssh & Web Terminal because for security, Frenck broke the ability to pass command after 9.1.1
Also, notifier add-on (Guido) is working fine too for me:
Hello,
I am absolutly new to homeassistant and I try to play audio files with home-assistent.
My homeassistant runs in a virtual enviroment (proxmox).I passed an audio USB stick to homeassistant. This also seems to work when I run paplay /media/alarm.wav in homeassistant’s terminal.
I now want to play the audio file when a lamp turns on.
But how do I use your scripts? Where do I insert them? And how do I connect them to an automation?
It would be great if you could give me a little help getting started
Hello Alex,
For the method below, you’ll have to use an old version of SSH&Web terminal, the 9.1.1
Here is an example of automation i use to play a sound when a device change his state. The automation call a script passing the audio file name as a variable. The script is the one in my previous message.
# Boule RGB salon ON
- id: boule_rgb_on
trigger:
- platform: state
entity_id: light.extended_color_light_19
from: 'off'
to: 'on'
condition: []
action:
#----------------------------------------
- service: script.turn_on
target:
entity_id: script.script_audio_input
data:
variables:
audiofile: /share/Speech_On.wav
#----------------------------------------
mode: single
PS: I apply same variable method with “notifier” add-on. If you play audio with notifier add-on, you don’t need to stay with an old SSH&Web version of course.
Hello Eddy,
many thanks for the quick response.
I completely overlooked the fact that an old version of the SSH&Web terminal has to be used. What a shame!
I couldn’t find Guido’s notifier anywhere. Is it perhaps no longer included in the home assistant OS 11.1, or am I missing something?
French version of HA: go to “Paramètres, Modules complémentaires…”
Good luck.
Eddy
PS: I’ll be playing Audio tests to an ESP32 with ESPHome 'cause i have to automate sound FX to a very old Xmas train
Hello,
Thank you very much for the great instructions, I tried the variant with MPD straight away and it works, with some limitations.
Unfortunately the sound is terrible. Maybe he’s oversteering? Is there a way to set the volume to 50%?
The variant with the notifier also works for me, unfortunately it doesn’t support stereo (or am I doing something wrong?). But stereo would be very helpful for me because I could control different rooms via the left or right channel. Is there a way to activate stereo on the Notifier?
Thank you again for your support, it helps me a lot!