I have a sound door.wav
which I can play via the console either via aplay or via omxplayer:
aplay /home-assistant/www/audio/door.wav
omxplayer /home-assistant/www/audio/door.wav
I can also access it via http://192.168.178.76:8123/local/audio/door.wav
.
But I fail to play it via a script within home assistant. I don’t have any smart speakers. Just normal speakers on the 3.5mm audio out of the Raspberry Pi.
My Setup
I run Home Assistant via Docker compose on a Raspberry Pi 2. The speaker is just on the normal audio output. My docker-compose.yml
looks like this:
version: '3'
services:
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
devices:
- /dev/snd:/dev/snd
volumes:
- /home-assistant:/config
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
privileged: true
network_mode: host
Approach 1: Shell Command
Adding this to my configuration.yaml:
shell_command:
doorbell: aplay /config/www/audio/door.wav
I then use service: shell_command.doorbell
. I see no error, but I don’t hear the sound either. I also don’t like this approach as I would need to restart home assistant for every sound I add.
Approach 2: Media Player
Adding this to my configuration.yaml:
media_player:
- platform: vlc
name: speaker
arguments: '--alsa-audio-device=hw:0,0'
Reading VLC media player - Home Assistant I guess the issue could be that I run Home Assistant via docker-compose?