Bluetooth speaker as media player

Hi @HaEsphomeTstr

  1. Have no clue. The steps I’ve taken was related with HA installation via Proxmox. Check if you can log into the console (via ssh or via “Terminal & SSH” add-on). If yes check if you can execute the comments from point I.6-I.18) - this is the crucial binding.
  2. dunno
  3. dunno, yet via Proxmox installation I’d need to add USB-dev as pass-through to HA then (in theory) it should be recognised - check it out accordingly → II.1-4
  4. I believe that is one-at-the-time type of connection. if you could find the way to select the master-output via script/param only. I never try it.
1 Like

Ok, thanks.

Got it to work following your instructions. From the “Terminal & SSH”:

bluetoothctl
scan on
pair (add MAC address here)
trust (add MAC address here)
connect (add MAC address here)
devices

6 Likes

Hello @HaEsphomeTstr ,

I’m struggling with this for so long (also with HA Blue) - I’m using the same commands and learnt even some more, but it just don’t show my devices at all or rarely just for a few seconds. I even bought a Bluetooth CSR 4.0 adapter (according to integration page recommendation for best performance), but it mostly won’t find it even when it’s sitting right on the speaker (I also tried many different speakers, all working great with other devices).

So I would like to ask you, what Bluetooth adapter exactly are you using? :slight_smile: (and where you bought it? - because most of these specifically listed on integration page are pretty difficult to find)

Hey I’m using Broadcom - BCM20702A0 (I’ve updated recently the instruction with info about BT used). In general here you have a list of BT compatible with HA - Bluetooth - Home Assistant

after “scan on” I’ve tried several time entering/re-entering pairing mode until you spot on the console a [NEW] device detected matching your MAC address. Then it should go forward with pair & trust.

1 Like

Yay, it worked! Thanks for the tip. The missing key for me was spamming that pairing command until it worked. Before I rather spammed scan on and devices to check if it sees it - and when I saw it in the list I tried pairing. Also, I had to throw away my CSR 4.0 adapter that just crashed during the pairing process and needed to restart everytime. Now I’m using EDIMAX BT-8500 which can successfully connect (after few restarts of HA and spam of pair commands).

Btw, here are my steps to get HA play media on BT speaker for others in future (as I always found small fragments of a solution, not a complete package):

  1. Do all previously mentioned stuff to pair and connect BT speaker.
    TLDR:
    Get BT adapter. Spam following commands until it works:
bluetoothctl scan on
bluetoothctl devices
bluetoothctl pair xx:xx:xx:xx:xx:xx //use address you find through devices command
bluetoothctl trust xx:xx:xx:xx:xx:xx
bluetoothctl connect xx:xx:xx:xx:xx:xx

Some extra useful commands:

bluetoothctl info xx:xx:xx:xx:xx:xx //to see if it's paired/connected/trusted successfully
bluetoothctl show //information about adapter
bluetoothctl help //to see all available commands/settings
  1. Get it registered as audio device with commands:
ha audio restart
ha audio reload
ha audio info

(repeat until you see it in info)
3) Get VLC add-on.
4) Set VLC to that new output (in add-on settings; needs restarting add-on)
5) Play media via interface or any automation (You can use action Play media or there are some advanced actions available as services - starting with media_player. )

13 Likes

Glad you got it to work for you.

1 Like

This is working for me, thank you for the write up :grin:

EDIT: Turns out I just skip the audio restart command and it works!

I’m trying this with a JBL Charge 4 with a ZEXMTE DG-69 adapter, running on a generic x86_64 machine, and every time I run “ha audio restart”, my speaker disconnects :frowning:

1 Like

Great write-up. Really appreciate summarizing it all in one spot. I’ve got this working nicely with a Roku Streambar.

However, we use the Streambar as an HDMI TV output source, plus my wife will connect to it over Bluetooth and stream her own playlists, etc. Additionally, we have the Streambar and everything else in the “entertainment center” on smartplugs that we turn off when we’re done using them. Once I had this all set up and working, I figured I’d test to see how HA/Linux/bluetoothctl handled the BT device being powered down and back up. As expected, VLC didn’t just work, even though bluetoothctl showed connected. I’ve tried cycling through these steps again, and it’s hit-or-miss. I suspect it is a timing issue. For now, we may just leave the Streambar on, but I wish it was all much more clean.

However, should I find the exact timing combo of these commands, is there a way to issue the bluetoothctl and ha audio commands in an ha script?

thank you so much :slight_smile: its working very well !

one question, it is possible to pair more than one BTS, and how to “name” or select to witch BTS i want to stream media ?

Hi all,

I connect a JBL3 Bluetooth speaker to HA which is working on the command line by bluetoothctl connect. The problem is, after restart, HA does not automatically connect to the Bluetooth speaker again. The device is paired and trusted, but I need to connect manually again.
Is there any way to add an auto connection to this device (maybe in configuration.yaml)?

hi. can you tell us, how to Get it registered as audio device with commands:???

I have the same issue. I can connect my Bluetooth speaker using bluetoothctl command, but don’t why “ha audio info” can’t show my speaker info.

I am following some GitHub projects to try to connect my Bluetooth speaker.

Hi All, when I enter the command “bluetoothctl scan on” in my Terminal inside HA, I am getting the following error: Unable to open mgmt_socket. Any ideas as to why?

I am running a HA Yellow Kit, with Bluetooth enabled and running well. I just want to add a bluetooth speaker to my HA.

I couldn’t get this to fully work.

Found the BT speaker, trusted and connected fine with the MAC, but when I ran the pactl list sink command I couldn’t see it to set it as the default. Only the dummy device which is already the default

I’m guessing that’s why I wasn’t able to see/add it to home assistant? :frowning:

Hi all,

I’m relatively newbie for HA/HAOS, however i’m working IT since 30y, using Linux since 1994 :nerd_face:
Anyway i connected BT Speaker to one RPI then shared via Pulse Audio to another RPI which is running HAOS as VM on SSD, now HAOS “see” BT Speaker over TCP :partying_face:
hassio-audio:/etc# pactl list sinks short
1 alsa_output.platform-fef05700.hdmi.hdmi-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
2 bluez_sink.5D_52_C9_8D_22_1C.a2dp_sink module-bluez5-device.c s16le 2ch 48000Hz RUNNING

Most trickiest part was to connect BT Speaker A2DP Profile Stereo NOT Mono headset Profile, anyone need help please let me know, happy to share my config files!

Actually it can be even more easily done with MPD add-on installed then BT Speaker is do NOT even needs to shared just configured with Pulse Audio on the Host where it MPD running the HA/HAOS can use this Speaker remotly!

Hi @Kali-777 I’m new to audio in HA/ Linux. It would be helpful to learn from you step-by-step how you got a Bluetooth speaker working.

Sure, happy to help, but what is Ur setup please, which OS or pure HAOS/etc… ? Coz i have kind of uniq setup, based on multiple RPI with RPI Debian OS…
BTW High-level steps basically are already here if U want to connect Ur speaker directly to HAOS, BT commands

However i connected to another RPI then shared which kind of “hard” way i realized is much more “easy”/simple with MPD addon on HAOS the MP Daemon where speaker is connected .

1 Like

Just got a JAM Classic 2.0 Bluetooth speaker to work with a Raspberry HA OS. Audio Notifications with TTS.

See GitHub - adrgumula/HomeAssitantBluetoothSpeaker: Home Assistant and Bluetooth speakers (based on the Xiaomi Mi Compact BLE Speaker 2 XMYX02YM)