Required a step-by-step guide on how to play sounds and media through a 3.5mm audio jack

Hi everyone

It’s a bit odd, I’m just trying to play sounds through my regular audio jack but I couldn’t find a guide or a post which explains how to do it.
I found some info in the documentation about VLC and MPD, but it wasn’t clear enough for me.
If someone can post here a step-by-step guide which explains how to make this setup, so eventually I will have an entity media_player.XXXX in which I can play sounds, that’ll be awesome.

The use case for me is to play sounds when automations are triggered. For example, I would like to hear a notification sound when the boiler is turned on, so I will know that the automation really worked (it’s a bummer to think that the boiler was on and then find out you don’t have any hot water).

I’m running my HA on a dedicated Debian based laptop, but it can also be relevant for RPi and any other configuration.

Many thanks!

1 Like

I don’t think I have read anyone doing this.
Most use either notifications through HA app or other messaging apps, notification through TTS on a smart speaker.

There is a DIY solution using a ESP somewhere in the forum.
But directly from the computer running HA is news to me…

Easiest way would be with the VLC addon:

Only plays sound files (e.g. mp3) does not do text to speech.

Thanks. I saw it, but the installation steps mentioned there were not enough for me to fully understand the installation process.

From the first link, how to install the VLC addon:

  1. Follow the steps on this tutorial to add this repository (GitHub - rodripf/hassio-local-vlc: Run a local VLC player on your home assistant installation) to your hassio installation.
  2. Refresh the add-ons using the white arrow on the top right of the page
  3. Search for “Local VLC” on the list and click on it
  4. Click on the install button and wait! It could take a couple of minutes.
  5. Configure a password for your telnet and web interface
  6. Configure your audio output device.
  7. Click on start!

From the second link, add this to your configuration. yaml file:

media_player:
  - platform: vlc_telnet
    host: IP_ADDRESS # this is the ip address of your home assistant server
    password: PASSWORD # this is the password you set up un step 5 above.

Restart home assistant and you should have a new meda player for VLC.

1 Like

Thanks.

I followed these instructions. When I try to trigger this -

service: media_player.play_media
data:
  media_content_id: 'media-source://media_source/local/PianoMan.mp3'
  media_content_type: audio/mp3
entity_id: media_player.vlc_telnet

I get in my log this -

Invalid media type audio/wav. Only music is supported
12:03:12 PM – vlc_telnet (ERROR) - message first occurred at 12:00:20 PM and shows up 3 times
YAML file /config/configuration.yaml contains duplicate key "media_player". Check lines 64 and 68
12:03:10 PM – util/yaml/loader.py (WARNING) - message first occurred at 12:00:17 PM and shows up 3 times
Error setting up entry configuration.yaml for mqtt
11:59:54 AM – components/mqtt/__init__.py (ERROR)

Try:

service: media_player.play_media
data:
  entity_id: media_player.vlc_telnet
  media_content_id: '/local/PianoMan.mp3'
  media_content_type: music

Your file should be in /config/www/ (maps to ‘/local’).

If you don’t have a www folder you have to restart after creating it.

Ok, now I get only this -

Error setting up entry configuration.yaml for mqtt
12:18:49 PM – components/mqtt/__init__.py (ERROR)

BTW, the file location is correct. For example, If I use media_player.shield (for my Nvidia Shield streamer) it works fine and plays the file.

Great. That has nothing to do with VLC (you should fixit though).

Thanks. Any directions where should I start?

Do you use mqtt?

Ok, following your question, I deleted in my configuration.yaml file the following -

mqtt:
   discovery: true

And now I don’t have any errors (can’t remember why I put those lines in the first place).
However, I still don’t hear any sound when I trigger the action.
Maybe I need to configure somewhere my audio output? Right now, under “configuration” tab in my “local VLC” addon, under “audio output” I have two options - “Default” and “Built In Analog Stereo”. None of them work. Note that I use an external USB sound card. But even when I tried to connect the 3.5mm cable directly to the audio jack, it didn’t work.
I would emphasize that I know that the sound card and cable work, because I tested them through the Debian terminal and it played my audio file.

  1. Is the VLC addon started? Check the supervisor / VLC addon page.

  2. Maybe the volume is turned down? Try setting the volume to 0.5 (range = 0 to 1) before playing.

service: media_player.volume_set
data:
  entity_id: media_player.vlc_telnet
  volume_level: 0.5
  1. Try my media source (with the file in /config/www) instead of the one you are using.
media_content_id: '/local/PianoMan.mp3'

I tried your suggestions, none of them worked for me. But now it’s clearer why there are problems. I looked at the log of Local VLC and saw the following errors:

[000055fdba05b900] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[000055fdba05b900] main interface error: no suitable interface module
[00007f3fd6c0fb40] main libvlc error: interface "dbus,none" initialization failed
[000055fdba0944a0] main interface error: no suitable interface module
[00007f3fd6c0fb40] main libvlc error: interface "globalhotkeys,none" initialization failed
[000055fdba05bac0] [telnet] lua interface: Listening on host "telnet://:4212".
[000055fdba058040] main playlist: playlist is empty
[000055fdba0963e0] [http] lua interface: Lua HTTP interface

Although it may sound like a non-VLC related issue, I googled the error which appears in the first line (D-Bus error) and per the results it is very much associated with VLC. Couldn’t find a solution in google.

I went searching and it seems that the VLC addon broke due to an update in how Home Assistant deals with audio sources.

Sorry, this is currently not a viable solution for your requirements.

Wow, I can’t believe it’s been 10 months and no solution for this.
:sleepy:
Maybe there is a possibility to use another media player?
Manny thanks for your help!

No problem, sorry for the bum steer. The only other method I know of is MPD and it is really not easy to do with Home Assistant OS.

As an alternative, the solution I implemented to this problem was to purchase a Chromecast Audio (still available second hand on fleabay) and hook it up to a pair of Creative Pebble speakers. One big advantage of this setup is that it can do text to speech rather than just relying on pre-recorded messages for announcements.

Also the Chromecast Audio is auto discovered. Very easy to add.

Downside is big brother data: Google.

Ok, sounds interesting. Indeed I have Chromecast built-in in my Nvidia Shield and the integration with HA is fairly intuitive.
Where do you connect the Chromecast? It’s HDMI powered, isn’t it?
And how do you connect the speakers to it?

Chromecast audio’s have a USB mini port for power, and a 3.5mm stereo jack for audio out.

This is what they were originally shipped with:

What's In The Box?

1x Chromecast Audio
1x 3.5mm analogue stereo patch cable
1x Power cable
1x Power adapter

The audio patch cable is only like 10cm long. 3.5mm stereo jack on either end.

On which Chromecast version are you referring to?