Skip to content

Add Bluetooth Speaker to HA ​

The Bluetooth integration in HA has very limited support to auto detect or scan for Bluetooth speaker. For this, we have to first pair the Bluetooth speaker to the VM running HA.

Hardware ​

Speaker: Anker Soundcore Motion+

Bluetooth Adapter: ASUS TUF motherboard built-in Bluetooth module

Prerequisite ​

First make sure you pass Bluetooth adapter to the HA VM.

Untitled

Then start the VM.

Pair Bluetooth Speaker on VM ​

First we have to login to HA OS as privilege user (root) in order to gain access to execute some privilege command and accessing folder in the terminal. To gain access to the terminal, make sure to use the VLC method or SSH to the VM, and NOT using the Terminal add on in HA. Using Terminal in HA won’t give you any access to modify a very important file in the HA Supervisor folder to set the default output to Bluetooth speaker.

Untitled

Untitled

After you login to the VM, type login to gain access to the privilege shell as root user.

Untitled

We will then use the bluetoothctl command to interact with the Bluetooth adapter hardware.

Replace 7C:96:D2:60:BC:4A with the MAC address of your bluetooth speaker that you see during Scanning.

python
login
bluetoothctl power on
bluetoothctl agent on
bluetoothctl default-agent
bluetoothctl scan on
bluetoothctl pair 7C:96:D2:60:BC:4A
bluetoothctl connect 7C:96:D2:60:BC:4A
bluetoothctl trust 7C:96:D2:60:BC:4A
exit

Example screenshot of different bluetoothctl command.

Untitled

exi

Following is the result when you activate the scan command.

Untitled

After pairing, we will then use a higher level command to reload the audio driver so HA can detect. If you see Dummy interface, that means it haven’t detect your Bluetooth speaker yet. In that case, repeat audio reload command several times until you see the loaded bluez driver and alsa.

Untitled

[NOT NEEDED] Set Default Output Device to the Bluetooth Speaker ​

Once we paired and connect the Bluetooth speaker to the VM, we will then set it as the default output.

Go to /mnt/data/supervisor/audio folder and make a copy of the asound file, which contains the configuration that tell the OS which sound output device to use as the default output device.

python
cp asound asound.bak

Replace the content of asound with the following. Replace device 7C:96:D2:60:BC:4A with the MAC address of your Bluetooth speaker.

python
TOBE ADDED

Screenshot showing the content of asound file.

Untitled

Install VLC Player Add-On ​

@ref: https://github.com/home-assistant/addons/blob/master/vlc/DOCS.md

First, install VLC Player add-on within HA so we can later playback any media to it.

Navigate in your Home Assistant frontend to Settings -> Add-ons -> Add-on store.

Untitled

Find the "VLC" add-on and click it.

Untitled

Click on the "INSTALL" button.

Untitled

You should see the following after installation. Toggle on Show in sidebar so we can access its UI there.

Untitled

Set Default Output in VLC Player Add-On ​

WARNING

It is very IMPORTANT to access the Configuration tab here and set the default output device to the Bluetooth speaker that we just connected. Without doing this there won’t be any audio playback to the VLC player when we play any music later.

Untitled

The VLC UI after clicking the sidebar icon. There isn’t any use here and we shouldn’t be using it anytime soon. Remember the goal is to playback any music files that we have in Music Assistant.

Untitled

Next, we will install VLC Player telnet integration so that we will have a media_player entity that connects to the VLC Player that we just installed in HA!

Install VLC Player TelNet Integration ​

Go to Settings > Devices & Services, and you should see the newly detected VLC player that we just installed locally. We need to add this Integration to HA so that this VLC player will appear as a media_player entity or type that we can later call using HA service call, especially when using Music Assistant.

Press the Configure button on the newly discovered core-vlc integration. This is the VLC Player Add-On that we just installed.

Untitled

Click Submit.

Untitled

Untitled

Untitled

Untitled

Set the

Add VLCTelnet media player to MusicAssistant ​

Go to Music Assistant settings, then select Home Assistant Media Players provider, and add it.

Untitled

Select the newly detected player.

Untitled

Profit! Enjoy the music playing to your Bluetooth speaker!

Untitled