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.
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.
After you login to the VM, type login
to gain access to the privilege shell as root user.
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.
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.
exi
Following is the result when you activate the scan command.
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.
[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.
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.
TOBE ADDED
Screenshot showing the content of asound
file.
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.
Find the "VLC" add-on and click it.
Click on the "INSTALL" button.
You should see the following after installation. Toggle on Show in sidebar
so we can access its UI there.
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.
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.
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.
Click Submit.
Set the
Add VLCTelnet media player to MusicAssistant â
Go to Music Assistant settings, then select Home Assistant Media Players
provider, and add it.
Select the newly detected player.
Profit! Enjoy the music playing to your Bluetooth speaker!