Bluetooth speaker as media player

Hello,

I have a bluetooth speaker and I want to use it as media player. I have a Intel NUC with Debian and HA container in host mode.

How could I configure it?

I will really appreciate any help.

Kind regards.

3 Likes

Search the forum this has been asked many times.

https://community.home-assistant.io/search?expanded=true&q=Bluetooth%20speaker

Thanks tom_l,

I searched for this, tehre are lots of post asking for info. But there is one working solution: https://github.com/pkozul/ha-tts-bluetooth-speaker

It is a custom component and it require some not easy configurations with OS and Pulse Audio software.

It will be great to have a easy way to integrate the bluetooth speakers.

Regards.

5 Likes

but all of them are very old thread and dont really have a solution yet, actually im looking for a solution to add bluetooth speaker to home assistant os too

3 Likes

Nothing has changed since then unfortunately.

Speakers are, well, speakers.
You have to have something that decodes audio files and send plain PCM to the speakers.
Unless HA, at some point, includes a “local” media player the same way it included a “local” media browser, you have to attach the speaker to an actual “media_player”.

The custom component mentioned above is doing basically that. Create a local media_player to which to attach the speakers to, via PulseAudio, which is one of the sound servers available on Linux.
And yeah, sound is a mess under Linux, which makes it more complicated than it should be :wink:

1 Like

Like many I to struggle to get a Bluetooth Speaker (BTS) to work with VLC as a mediaplayer on my Pi4 installed with haos_rpi4-64-6.5.img.xz. So, this is my progress on this matter:

  1. Configure BTS in HA but failed to work
  • Add / discover BTS.
  • Paired BTS
  • In HA, BTS dont get listed in VLC audio list
    So, to check VLC as a mediaplayer…
  1. Test VLC mediaplayer with analogue speaker - send TTS messages - Worked

Then to check BTS - VLC - PI, I thought of testing the BTS / VLC on another pi and it worked.
3) Test Bluetooth speaker on a another pi3b+.

  • Install VLC
  • Pair BS
  • Listen to a online radio station - Worked

The PI 4 analogue audio work but BTS dont work.
SO,
how do one add / config haos_rpi4-64-6.5 to list a BTS as an audio device in VLC on a PI4 given that may suggestions the setup is different from HAOS.

Looking forward to suggestions.

Hello Everyone !!!
Any solution on this ? any new development on this topic?
Looking forward to suggestions.

4 Likes

I am wondering the same. I want to be able to push a button and have my 12 hour sleep music soundtrack play. I tried with Alexa but it seems limited to 240s. I got it working with Google Home, but then I don’t see any way to turn the screen off while music is playing which kind of kills it. I may try the tts-bluetooth-speaker above, but it looks difficult to setup and maintain especially since I use HA in a docker container.

Bluetooth speaker and mpd integration in HA.

On your host install mpd, edit Mpd configuration in /etc of your host and make this your only output


audio_output {
type"alsa"
name"JBL GO 2"
device"bluealsa:DEV=70:99:1C:D1:0C:EE,PROFILE=a2dp"
}

To have volume control using HA this bellow type above

mixer_type      "software"    

The 70:99:1C:D1:0C:EE is my own speaker, there you should put yours, you can change the name as well.

Then using bluetoothctl pair and trust and connect to your speaker. Then in /etc edit asound.conf and add this


pcm.mid {
type plug
slave {
pcm {
type bluealsa
device 70:99:1C:D1:0C:EE
profile "a2dp"
}
}
hint {
show on
description "JBL GO 2"
}
}

Again instead of 70:99:1C:D1:0C:EE add your Bluetooth speaker, also you can change the description.

Make a script that will run on startup that will connect to your Bluetooth speaker on every boot.
Make a script that will run mpd on every boot.

In Ha add mpd in your ha config and as host IP of mpd add your HA instance IP (since it’s the same IP as the host you are running it on)

Restart and have mpd player in ha play sound through Bluetooth speaker

4 Likes

Hi, does this also work under HA-OS (Home Assistant Operating System) ?
All files seems read-only and not changable with chmod …

1 Like

No, only if you got a host system that’s running ha instance

1 Like

This is the one thing that irritates me about HA. I want to use HA as an “appliance” but cannot because I would like to play a media file to a Bluetooth speaker continuously. It doesn’t make sense to have a whole separate device set up, so I use VLC and HA Supervised on Netrunner Linux, all running on a Dell/Wyse thin client. It works fine, but I’d really like to not have to maintain a separate Linux version for a single application. Having HA-OS playing the file would make everything perfect.

2 Likes

Through ssh into your ha os try this


apk add --no-cache bluez bluez-deprecated alsa-utils alsa-utils-doc alsa-lib alsaconf

apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing bluez-alsa

Haven’t tested this but it should work.
Since ha os is based on alpine Linux this should add bluez and with that you’ll be able to run bluetoothctl and connect to your speaker. Once that is done follow the things I’ve said above. Install mpd for alpine Linux as well. This should theoretically allow Bluetooth speaker to work with mpd and connect automatically on every boot on home assistant os.

2 Likes

Tanks for the info.

I am afraid, that this won’t work , because changing files in HA OS is not possible since this is a read-only-filesytem.

I can pair, trust and connect my speaker with bluetoothctl, so that’s working OK. But changing files does not work.

Manually change by editing the file on your pc ( running any live Linux and then mounting the hard drive or sd card with your ha os) then changing manually there.

1 Like

Thanks but sorry, you’re a littel too fast her. I think I get the idea, but can you give some more details, as I do not know Linux very well.

Download Ubuntu live iso, download virtualbox ( software for virtual systems so you don’t need to install any other os on your pc) , boot the iso in the virtualBox, once you have Ubuntu running in virtualbox, take the ha os sd card, plug it in your computer, access it using Ubuntu Linux in virtualbox, then edit those files that are located in the ha os sd card.

1 Like

Ok, clear. Thanks, I wil try.

I forgot about this

You don’t need to install virtualbox or use Ubuntu. You can do it all the using ssh and 22222 port as written about in the link above, it gives you root access so you can edit all files needed through ssh.

1 Like