Bluetooth speaker as media player

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

2 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

Thanks,

Got access with port 22222.
It’s hard to find the right files.
(multiple asound.conf files found, all were 0 bytes but the read-only asound.conf file I found when using port 22 has content and is not 0 bytes )
Any idea how to get the right files?

nano /etc/asound.conf

Edit and add what I’ve posted above with your own Bluetooth speaker address.
( or vim instead of nano or whatever editor you prefer )

When I search for asound.conf (find / -name asound.conf) I get:

/mnt/data/docker/overlay2/11d4ecaacaa0eeea50ef1bf4169b440d2b4decfef2a3bb250f54fbb95397362b/merged/etc/asound.conf
/mnt/data/docker/overlay2/11d4ecaacaa0eeea50ef1bf4169b440d2b4decfef2a3bb250f54fbb95397362b/diff/etc/asound.conf
/mnt/data/docker/overlay2/5ab2741760faad74f4d3cbe442c777182cd0e0db48efd59307845f6500b80461/merged/etc/asound.conf
/mnt/data/docker/overlay2/5ab2741760faad74f4d3cbe442c777182cd0e0db48efd59307845f6500b80461/diff/etc/asound.conf
/mnt/data/docker/overlay2/da8334033556f741532d53ac8b10f3cbb2ca04d384562563a446a7f0ebd1e5ad/diff/etc/asound.conf
/mnt/data/docker/overlay2/4e913c57b8e7f916c8fe9c96e3d9ecd3b17ea3c6ef0bfcaebe52fef7b9861d5e/diff/etc/asound.conf
/var/lib/docker/overlay2/11d4ecaacaa0eeea50ef1bf4169b440d2b4decfef2a3bb250f54fbb95397362b/merged/etc/asound.conf
/var/lib/docker/overlay2/11d4ecaacaa0eeea50ef1bf4169b440d2b4decfef2a3bb250f54fbb95397362b/diff/etc/asound.conf
/var/lib/docker/overlay2/5ab2741760faad74f4d3cbe442c777182cd0e0db48efd59307845f6500b80461/merged/etc/asound.conf
/var/lib/docker/overlay2/5ab2741760faad74f4d3cbe442c777182cd0e0db48efd59307845f6500b80461/diff/etc/asound.conf
/var/lib/docker/overlay2/da8334033556f741532d53ac8b10f3cbb2ca04d384562563a446a7f0ebd1e5ad/diff/etc/asound.conf
/var/lib/docker/overlay2/4e913c57b8e7f916c8fe9c96e3d9ecd3b17ea3c6ef0bfcaebe52fef7b9861d5e/diff/etc/asound.conf

No /etc/asound.conf found here.

Create it in etc, it should override the docker ones as the one it etc is the main one (global one), it should be active after reboot.