Play Audio Through The Home Assistant Computer

Play Audio Through The Home Assistant Computer

In previous posts, I’ve covered how to play sounds from Alexa speakers and even how to send sounds to your phone via WhatsApp. But there’s another useful way to play sounds: directly from the computer that runs your Home Assistant. Whether your Home Assistant is installed on a Raspberry Pi, a NAS like Unraid, or another platform, chances are it can play sounds through connected speakers or, as in my setup, Bluetooth speakers.

Requirements

Although you’re more than welcome to just read this post for general knowledge, check out my recommendations for what you need to have, in order to be able to fully use the provided information.

Why VLC?

I’ve explored multiple options, and the most reliable method I’ve found is using the VLC add-on. For those unfamiliar with VLC, it’s an open-source media player that can handle a wide variety of audio and video formats. By adding it to Home Assistant, you can play audio files like MP3s directly from your Home Assistant machine.

Installing the VLC Add-on

Adding VLC to your Home Assistant setup is a straightforward process:

  1. Navigate to Settings -> Add-ons -> Add-on store in the Home Assistant frontend.
  2. Find the "VLC" add-on in the list and click it.
  3. Hit the INSTALL button.

Once installed, Home Assistant may automatically discover the VLC integration. If not, you can install it manually by searching for the VLC Telnet integration. Or, to make it even easier, you can use this link to add it directly.

Setting Up Audio Playback

Now that you have VLC installed, you can play audio files stored in one of your Home Assistant media locations. Here’s a script example you can use to play any audio file. Just replace the file name in the script with your own audio file:

  - service: media_player.play_media
    metadata:
      title: dog-barking-70772.mp3
      thumbnail:
      media_class: music
      children_media_class:
      navigateIds:
      - {}
      - media_content_type: app
        media_content_id: media-source://media_source
    data:
      media_content_id: media-source://media_source/local/dog-barking-70772.mp3
      media_content_type: audio/mpeg
    target:
      entity_id: media_player.vlc_telnet
    enabled: true

Replace "dog-barking-70772.mp3" with the name of the audio file you want to play. This script works by targeting the VLC Telnet media player entity, which is created when you install the VLC add-on and integration.

Conclusion

By using the VLC add-on, you can easily play audio directly through your Home Assistant machine. This method is flexible, allowing you to connect speakers to your Home Assistant device and control audio playback within your smart home. I'm not entirely sure what practical use this has, if you think of some cool way of using it, do let me know if the comments below!


Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply