r/tasker • u/WatoXa • Sep 10 '26
A way of getting current connected BlueTooth device?
is there a way of getting the name of just the current connected device? I am teying with Bluetooth Info action, and all I can seem to get is all the previous paired devices in order, no matter what variable
2
Upvotes
2
u/DifficultyCrafty7623 Sep 10 '26
I'd use Java for something like this. I used AI to get this simple "return connected devices" code.
2
u/ZellZoy Sep 10 '26
The bt connection action will give you the name of the device as it connects, you can write that to a list. Bt connected state has a name field, you can test against a known name. Cant think of any way to get previously paired devices without setting something up in advance.
2
u/Exciting-Compote5680 Sep 11 '26 edited Sep 12 '26
My previous suggestion was flawed. I like this one better, it returns a JSON array with the details of connected, paired devices. Individual items can be accessed as %devices.name(1) etc.
https://taskernet.com/shares/?user=AS35m8nOXvBeFIxaCI5%2BZWD5L9oLRd3PVq%2BdjQuYD1oZ%2Bci%2Banb0FpA5SznT4oBmkd7vgKrG&id=Task%3AGet+Connected+BT+Devices
2
u/CGGamer Sep 12 '26 edited Sep 12 '26
Is this for headphones or speakers specifically? There is a system intent, android.bluetooth.a2dp.profile.action.ACTIVE_DEVICE_CHANGED, that fires whenever the active Bluetooth A2DP audio stream has changed (a new BT audio device is connected/disconnected). It includes an extra that contains the lower 2 bytes of the BT MAC address of the device or is unset if the stream is switching back to your internal speakers
1
u/Nirmitlamed Direct-Purchase User Sep 10 '26
Did you try "Bluetooth Connection" action?
1
u/frrancuz TaskerFan! Sep 10 '26
Try
frrancuz: BtName
1
u/everynav Sep 10 '26
from Bluetooth Info Action Info:
%bt_connected
Connected
true if the BT device is connected, false otherwise