Bluetooth audio auto connect

edit: no, the script is no longer necessary

I told you so ;). It works for me with the stable release, no need to use the nightly build.

just auto connect still does not work

Does it work with the script? I was thinking about working out a simple systemd unit that tried bluetoothctl connect MACADDR. But not sure it’s worth the effort.

Wow thank you so much !! Thats work perfectly with my coreelec 9xx / TX8 box !!! THANKS

Any news here?can someone give me a solution for auto connect Bluetooth on latest 9.2.0 build please?

The Bluetooth Audio Switcher default setting only works if you are using the default audio output when NOT using Bluetooth. My ODroid N2 has 6 audio options, and I’m using the 6th one (HDMI) - not the default. Had to get help figuring out what to enter in the setting. Found I had to do “aplay -L” from the terminal to get the correct text to enter for the setting. This is very poorly documented.

Unfortunately this only addresses switching to Bluetooth once it’s connected or back to other audio if BT disconnected. Neither of my BT headsets will auto-connect to CoreElec, I have to do it manually through Settings-CoreElec-Bluetooth. These BT headsets auto-connect to everything else I own w/o issue.

Update - I’m not a CE or code guru, but after looking closely at this I think it’s an equivalent to the BT audio switcher, it appears it’s waiting for an event that adds the BT audio device (the auto-connect we are all looking for). So this assumes the BT device has already auto-connected, which mine don’t. That’s the part I need.

Old:
I believe this is the udev rules and script others have referred to with regard to auto-connecting bluetooth, but doesn’t work for me. The script actually broke (overrides) the BT audio switcher add-on which I just got working as it does not appear to accept the same text for the non-BT audio device that the BT audio switcher add-on does. https://gist.github.com/witokondoria/8f61143136dd15d0c7d72c47867dc859#file-bluetoothhandler-sh

Hi! I have contacted vevs and he was kind enough to provide a really working solution for surround sound system users!!
I have a 5.1 surround sound and I have Passthough acivated to let the AVR the encoding of the audio signal. If the passthrough is activated the sound comes still from the 5.1 system. I have asked vevs to ehance the script to automatically disable audio passthrough once the bluetooth headphones are connected. It is working perfectly!! Just place the two files in your configfiles here \YOURIP\Configfiles\udev.rules.d
It works immediately! Dont forget to enable HTTP control under services. It is working like a charm. Maybe CoreELEC team will implement this in the future releases? This script is better than Bluetooth Audio Changer. It also disables passthrough when Headphones are connected.
Here are the files:https://www.mediafire.com/file/5tgvle9trsv4quw/bluetooth_audio_autoswitch.7z/file

1 Like

I think bluetooth sucks in geneal. I tested with Redmi Airdots and my results:

  • on Android: as soon as I power on headphones, Android immediately connects and audio is automatically switched to Bluetooth. When power off headphones, audio is again on speaker
  • on Coreelec: tried to connect/pair. After 10th attempt, with various error messages like “no response from device”, “function not implemented” and some others I don’t remember, finally it connected. But, unfortunately, only right earphobe. So, again a few attempts and it finally worked. However, with 2 seconds sound lag. Of course, when power off device, Coreelec never switch to hdmi audio, as well as it never connect automatically when device appears. It also never connect to available device after boot. It sticks to bt audio output setting, without even any attempt to auto connect to device and there’s no sound. If audio output is set to hdmi, it never attempts to connect to bluetooth and switch to bluetooth audio as Android do

In my case, it’s useless. Maybe it only exists for fun. But not for use. If somebody thinks about BT audio on Coreelec, forget it. Nothing more than waste of time, unless you have nerves of steel

1 Like

Bluetooth audio automatic connection and automatic switch to bluetooth audio when connected got reworked in CE-19 already. I will try to backport it for CE-9.2

In general bluetooth is a bit complicated about connect/reconnect. Some devices have no issues, some need manual interaction, some do not work at all.

EDIT:
the bluetooth changes should be also in tomorrow 9.2 nightly

3 Likes

Thank you! Tested it! Working now with the bluetooth even if passthrough is enabled. But I had to switch Audio Source after connecting the bt device and had to switch back to HDMI PCM when the device was disabled. Maybe you can fix this? The button switch audio source doesn’t work. Will try the CE 19 maybe too.
Thank you for your work!

when you change this option to switch audio source you need to reboot one time as kodi need to be reloaded to get the new settings active. when you have the option enabled and you see the notify pop up BT connected/disconnected it should also switch the audio device. for error handling turn on debug logging in kodi and provide a kodi.log

I did install newest nightly from CE19. Bluetooth autoswitch is working here!! did not work on 9.2
PLEASE make it so that passthough gets disabled once bluetooth is connected. i have to disable passthough to hear anything in for example netflix. It does not make sense or this is the error in logic of the audio settings. I think when bt headphones are connected the passthrough function should be disabled. Because there is: passthough device: HDMI and bt headphones cannot decode sound but i like when my AVR is doing it.

1 Like

same to me. I 2nd that!

1 Like
d7336cbe8c: Fri Jan 29 10:07:03 2021 +0100 – CoreELEC-settings: bump package to 5eac7b49 turn off passthrough when BT audio device get switched (Portisch)

We love you! :slight_smile:

2 Likes

Bluetooth autoswitching (connect and disconnect) works well with my C4 and a LogiLink USB-BT adapter on nightly_20210130, also disabling passthrough when BT is connected and enabling it again when BT disconnects.

I had to disable/uninstall the AddOn “Bluetooth Audio Device Changer” from the CoreELEC Nightly Add-ons repository, otherwise the passthrough ensbling/disabling does not work correctly. It costed me hours to recognize this…

But now: thanks a lot, @Portisch

2 Likes

Yes, the addon must be removed. forgot about it…

1 Like

My device is passive, so it won’t initiate connection, Kodi needs to do that. Is it possible? There’s no option “auto connect” in CE BT settings for particular device

Right now it tries each device what was connected before one time to reconnect after kodi is started.
So when here the device is already powered it should be connected. When you power it on after kodi is started it needs to be the client to try to establish a connection. Not sure what happens if Kodi run in endless loop and try to connect a bt device.

1 Like

There used to be a good (perfect) solution for Bluetooth auto connect (via udev rules), but it got broken somewhere around april 2020. cdu13a tried to look into it back then, but could find a fix. I didn’t update my CE installations since then anymore because I don’t want to lose this feature which I use every day. It is described here: Nightly builds (NEW)
Is it still broken?

GunterO, I was testing this version with udev and it worked few weeks back: https://pastebin.com/vMXsj5MA

But now it is not needed anyway.

2 Likes

Thanks for confirming this. I guess I can start upgrading again :slight_smile: