1
Solved

Bluetooth disconnect device not working?

Hi,

I want a Task that will disconnect my headphones. So I created a Bluetooth Connection Task as you'd expect but when I execute it, the headphones are still connected. 

Any tips on what I should be doing? I've tried matching by MAC address and name to no avail. 

Exported XML:

<TaskerData sr="" dvi="1" tv="5.9.2">

 <Task sr="task21">

  <cdate>1581970422342</cdate>

  <edate>1581981740940</edate>

  <id>21</id>

  <nme>Disconnect BT</nme>

  <pri>100</pri>

  <Action sr="act0" ve="7">

   <code>340</code>

   <Bundle sr="arg0">

    <Vals sr="val">

     <net.dinglisch.android.tasker.RELEVANT_VARIABLES>&lt;StringArray sr=""&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0&gt;%bt_address

Address

Bluetooth device's MAC address&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1&gt;%bt_battery_level

Battery Level

% of battery available, or not set if unavailable. (Android 9+)&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2&gt;%bt_paired

Paired

true if there is at least one encrypted connection to this device, false otherwise&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES3&gt;%bt_class

Class

The device's bluetooth class ID&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES3&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES4&gt;%bt_class_name

Class Name

The device's bluetooth class name&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES4&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES5&gt;%bt_connected

Connected

true if the BT device is connected, false otherwise&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES5&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES6&gt;%bt_encrypted

Encrypted

true if there is at least one encrypted connection to this device, false otherwise&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES6&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES7&gt;%bt_major_class

Major Class

The device's major bluetooth class ID&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES7&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES8&gt;%bt_major_class_name

Major Class Name

The device's major bluetooth class name&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES8&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES9&gt;%bt_name

Name

Bluetooth device's name&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES9&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES10&gt;%bt_signal_strength

Signal Strength

Strength of the connection in dBm. Only available for connected and scanned devices.&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES10&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES11&gt;%bt_type

Type

Could be 'classic', 'le', 'dual' or 'unknown'&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES11&gt;&lt;/StringArray&gt;</net.dinglisch.android.tasker.RELEVANT_VARIABLES>

     <net.dinglisch.android.tasker.RELEVANT_VARIABLES-type>[Ljava.lang.String;</net.dinglisch.android.tasker.RELEVANT_VARIABLES-type>

    </Vals>

   </Bundle>

   <Int sr="arg1" val="1"/>

   <Str sr="arg2" ve="3">M&amp;D MW07 PLUS R</Str>

   <Int sr="arg3" val="60"/>

  </Action>

  <Img sr="icn" ve="2">

   <nme>mw_device_bluetooth_disabled</nme>

  </Img>

 </Task>

</TaskerData>

Any help appreciated!

5 replies

That's interesting, I wonder why they don't have an API for it. Thanks anyway!

Hi, so you have any idea what might be wrong? My phone is a OnePlus 6T, not rooted. 

Thanks.  

Unfortunately the disconnect API is not officially available for apps to use. I had to use a workaround to access it. Maybe because of this some manufacturers or devices don't properly implement it... :(

Yeah I tried that already I'm afraid. BTW I have the Master & Dynamic wireless buds and they show up as two distinct BT devices in Android (L and R). I tried disconnecting each one answered also both, to no avail. 
Cheers. 

    Disconnect BT (21)

    A1: Bluetooth Connection [ Action:Disconnect Device:M&D MW07 PLUS R Timeout (Seconds):60 ] 

     

Thanks for your prompt help!

Pete

Can you please try using the device's mac address and see if that makes it work?

Can you please export your task's description (not xml) so I can take a look? Long-click the task in Tasker->export description Thanks in advance

Topic is closed for comments