What is wrong with the auto generated automation script?
System sound working just fine.
Absolute directory is '/media/file.mp3
Card on Dashboard shows file playing, but no sound.
action:
- service: media_player.play_media
target:
entity_id: media_player.vlc_telnet
data:
media_content_id: '/media/classic-door-bell.mp3'
media_content_type: music
metadata: {}
mode: single
Dear Guido, I get an error when I start an automation with local audio play:
wget: error getting response: Invalid argument
play FAIL formats: can’t open input file URL `http://localhost:8123/local/beep.mp3’:
[12:35:44] ERROR: Invalid audio
I don’t configure the path for audio files, only copied mp3 to config/www folder.
Could you help me?
I tried the VLC addon a while ago, and found that it would often fail to play my audio, or be very choppy in its play back and never found a solution. Its possible its better now, or something specific in my setup caused the issue (virtual box on windows running HAOS) and how audio is passed through.
In the end I went a different direction using an old mobile phone I had lying around using the bubbleupnp app. I can now select the phone as a media player, and use its 3.5mm jack to output the audio to any connected speaker.
It’s worked, played the test song.
I think the issue is with source path: I use DuckDNS add-on and I can’t acces with local IP for HA, only with Duckdns. So this path: (`http://localhost:8123/local/beep.mp3’ isn’t correct.
How can I configure this correctly?
yes, the problem is the local access. I changed configuration.yaml and removed duckdns registry and installed and configured nginx. After that everything works fine! Thank you!
This solution is not good for me. I need DuckDNS, but with dnsmasq I can access in local network only with https. So this path is not good for me: http://localhost:8123/local/
could I change it?
At the moment (April 2024) the following setup works without any add-ons:
You will need Pulse Audio client binaries (pacat, paplay, pactl). They used to be present in the main HA container, but were removed. However, all libraries required by those binaries are still present in the main container
Take those binaries from the hassio_audio container and copy them to /media as follows:
These commands can be run either from the host OS (if you have access to it, e.g. you are running HA supervised) or from the Advanced Terminal add-on. While doing this, you can verify whether HA would send the sound to the sound card you are expecting: run pactl info and verify whether “Default sink” is showing what you are expecting. If you have access to the host OS, the command would be: docker exec -it hassio_audio /usr/bin/pactl info.
I read this thread some time ago but just revisited the issue. There is an official VLC add-on in the Settings > Add-ons > ADD_ON STORE.
This installs and runs the add-on under the HA OS. No manual config file editing, no yaml or other code needed. You may have to configure its inputs and outputs in the add-on’s Configuration tab (two pull-down menus), although defaults worked for me. Then you start the add-on (check the log tab for errors and if all looks good, enable the watchdog and start on boot).
With the add-on running (and this part is key), you go to Settings > Devices & Services, and should have the VLC telnet integration auto-discovered. You add it (again, via UI - no manual config needed) and there’s not much to do after that. Everything should just work out of the box - or at least it did for me on 3 HA OS instances I’ve done this so far.
If you’ve some VLC integration manual install config entries pre-dating this, you may have to take it out and clean that up very thoroughly and redo this procedure.
When running the command from Advanced SSH & Web Terminal it works fine. When running from an automation I get “return code: 127” in the logs.
Running pactl info > meh.txt works and I get the output in the meh file, but paplay won’t budge, return code 127 no matter what I do with this command. It’s also not permissions as the file is 777 and I can make the pacat work using /config/scripts/pacat --list-file-formats -v > meh.txt again. But it won’t play
Several versions ago HA removed PulseAudio libraries from the main container (in addition to the binaries which were removed even earlier). This breaks the setup described in my earlier post.
Solution: to copy the required library from hassio_audio to the same location on the host machine, to which the binaries were copied before. There is one additional command besides the ones I listed in my previous post:
It’s using the network to play the audio. Audio plays fine when using the command from within the Advanced SSH and Web Terminal addon from within Home Assistant:
I gave up trying to make it work. I simply connect to the host using SSH and play the audio there. Audio file needs to be on the host. It’s a bit overkil, but at least it’s also futureproof as it doesn’t depend on any configuration in the homeassistant container itself.
You do need to setup SSH rsa keys for a ‘ha_audio’-like user on the host ofc.