Page 1 of 1

Bluetooth disconnect trigger issue.

Posted: 06 Jul 2013 07:51
by bener
Hi... I am trying to use the bluetooth device disconnected trigger, in the manner described on the site: "The trigger Bluetooth Device Disconnected is executed when a bluetooth device is disconnected".

I want a simple flow - Bluetooth device disconnected = Set bluetooth state: off. When I turn off my car, I want the bluetooth to turn off. I will re-enable manually so that's not an issue.
It's really just there because I forget to turn off my bluetooth all the time.

The problem is, when I turn my bluetooth on and it starts making a connection with my bluetooth head unit (e.g. while it is in the process of 'pairing'), the flow is triggered.
Is this a bug, or am I setting it up wrong? I took the description to mean it will trigger 'when disconnection happens' not 'if a device currently disconnected'.

It does not trigger if I just turn bluetooth on and leave it, with no device on to connect to, so it appears to be working properly in that sense.

Any help would be much appreciated!

Re: Bluetooth disconnect trigger issue.

Posted: 06 Jul 2013 11:13
by MURTUMA
You should put a sleep action for a few seconds before the bluetooth condition. The connection takes a few seconds to create and without the sleep action, the bluetooth triggers when there is not yet connection.

That should fix your flow.

Re: Bluetooth disconnect trigger issue.

Posted: 06 Jul 2013 12:59
by Martin
Hi,

I'm not sure what's going on. Can you publish the flow in question here (or send to info@automagic4android.com) and check the log (menu->Manage->Log) and see if the device executes the flow when you connect the BT device. Please also ensure that the trigger box only contains one trigger and not an additional trigger 'Bluetooth device connected'. Perhaps the bluetooth device immediately disconnects and immediately reconnects again.

Regards,
Martin

Re: Bluetooth disconnect trigger issue.

Posted: 06 Jul 2013 13:30
by bener
Thanks for your response murtuma, the problem is that I need the trigger to be 'bluetooth device disconnect' and the app
seems to be recognizing my phone/car unit pairing process as that trigger - as soon as the devices begin to pair
(lights on car unit flash to show this) the flow is triggered, turning off the bluetooth.

Re: Bluetooth disconnect trigger issue.

Posted: 06 Jul 2013 13:47
by bener
Hi there Martin, I am happy to publish it here to keep a reference in the forums, it appears that the app is recognising
the bluetooth pairing process as a 'bluetooth device disconnected' trigger - it could just be the way my car
unit pairs - it connects phone and media at the same time so it could be sending some kind of misleading signals...

The flow was very simple: Bluetooth Device Disconnected: All devices --> Set Bluetooth State: Off
It just seems to be getting triggered by the wrong thing.

I am now going to aim for a flow that triggers on an incoming call, checks for bluetooth status, turns on if necessary,
sleeps, then turns off if not connected, or at end of call if connected.

As a side note, is there a way I can create a 'bluetooth connected: yes' trigger? It would then be very easy to add
the function of 'if bluetooth connected, turn off at end of call, else turn off now' after a 15sec sleep.

Thanks a lot for responding.

Re: Bluetooth disconnect trigger issue.

Posted: 06 Jul 2013 14:11
by MURTUMA
Sorry, I somehow thought that you're using condition and not trigger.

Re: Bluetooth disconnect trigger issue.

Posted: 06 Jul 2013 14:42
by Martin
Hi,

You can enable 'Debug Log' in the preferences of Automagic to check if the device generates a disconnect event when the car connects. The events are recorded to the log accessible in menu->Manage->Log (at least one trigger Bluetooth Device Disconnected needs to be enabled to get the log entry in Automagic)

The next version of Automagic will introduce a new condition to check if a bluetooth device is currently connected or not. This will greatly simplify to build workarounds for such issues. You will be able to build a flow that waits after a disconnect event for one or two seconds and then checks the condition to see whether the device is still disconnected before you turn off the BT adapter.

You could try to build flows to remember the state of the bluetooth device by using a global variable:
Flow1:
-trigger "Bluetooth Device Connected: XYZ"
-action "Script: global_bt_dev_xyz_connected=true"

Flow2:
-trigger "Bluetooth Device Disconnected XYZ"
-action "Script: global_bt_dev_xyz_connected=false"

and use a condition in another flow to check the value of the variable:
Flow3:
-trigger ...
-condition "Expression: global_bt_dev_xyz_connected"
-->true: action "Set Bluetooth State: Off"
-->false: action "Sleep: 15s", action "Set Bluetooth State: Off"

What Device and Android version are you using?

Regards,
Martin

Re: Bluetooth disconnect trigger issue.

Posted: 07 Jul 2013 13:43
by bener
Thanks Martin, that new feature is exactly what I am looking for, cheers!

Re: Bluetooth disconnect trigger issue.

Posted: 07 Jul 2013 13:44
by bener
It is an HTC Sensation with JB custom ROM XenonHD...