I'm trying to connect to a Bluetooth device... but it is not working.
I am able to turn on and off the Bluetooth device... but it doesn't go further than that.
I was wondering that what could be the reason??? BTT has permission to access bluetooth.
When connecting things (be it Bluteooth, USB, WiFi, barbed wire, whatever) - I've noticed that delays make things work better. Add a second or two between the events to give the devices time to discover each other.
Well, you told it to show "Connected" no matter what. So it does.
If you want different messages you will have to use some more logic. I can't find any Bluetooth variables in BTT, but the shell command system_profiler SPBluetoothDataType will list all your devices, with the connected ones listed first. With some grepping and scripting, you can get the info from that.
You can also do it quick and dirty, since you are enabling/disabling the BT adapter. Just check if it is enabled. Add a "If Javascript returns true" action, and put this code in it:
async function someJavaScriptFunction() {
let result = await runShellScript({script: 'system_profiler SPBluetoothDataType | grep "State: On" | wc -l'});
return result;
}