I am attempting to create a workflow to easily manage headset/car connections with my smart watch (Samsung Gear S3, if it matters), so that when I connect to my headset/car, my watch disconnects, allowing the headset to connect, and then when the headset disconnects, reconnect to the watch.
When I do this as a single workflow for each device, the workflow works well, and looks like this:
1. TRIGGER - Bluetooth device connected: Headset
2. CONDITION IS TRUE - Bluetooth device connected: Gear S3
3. ACTION - Disconnect Bluetooth Device: Gear S3
4. ACTION - Connect Bluetooth Device: Headset
However, this requires a new workflow for each device I connect. Instead, I'd like to have a single workflow that handles all my devices. It seems to me that the workflow would need to work like this:
1. MULTIPLE TRIGGERS - Bluetooth device connected: Headset OR Car OR Speaker
2. ACTION - Init Variable with new device that is connecting
3. ACTION - Disconnect Bluetooth Device: Gear S3
4. ACTION - Connect Bluetooth Device: New device connecting
Is this possible? The kicker seems to be steps 2 & 4 - how do I save the new device connecting to a variable, and how do I then use that varible to connect to the new device?
Even better would be if I could create a trigger with a condition saying "Any device with a headset profile that connects EXCEPT FOR my watch," but one step at a time.
Store Connecting Bluetooth Device in Variable
Moderator: Martin
Re: Store Connecting Bluetooth Device in Variable
You can follow your current workflow, by using multiple triggers, as many device as you need. Add all the Bluetooth Device Connected name (you have to do this for every new device too) and use expression
Then if true, disconnect Gear S3 and connect bluetooth device : put {address} provided by the trigger in the address. This is the hard way.
============================
OR, you can simply negate the logic and check only if the connected one IS NOT Gear S3.
Trigger : Bluetooth device connected : all
Condition : Bluetooth device connected: Gear S3
use the False branch (so only when the connected device IS NOT Gear S3), disconnect Gear S3 and connect the new device. You don't have to add anything for any new bluetooth device, it is a time creation flow, set and forget.
Code: Select all
containsElement(newList(
"Bluetooth Device Connected: Headset",
"Bluetooth Device Connected: Car",
"Bluetooth Device Connected: Speaker"
), trigger)
============================
OR, you can simply negate the logic and check only if the connected one IS NOT Gear S3.
Trigger : Bluetooth device connected : all
Condition : Bluetooth device connected: Gear S3
use the False branch (so only when the connected device IS NOT Gear S3), disconnect Gear S3 and connect the new device. You don't have to add anything for any new bluetooth device, it is a time creation flow, set and forget.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Store Connecting Bluetooth Device in Variable
I thought about using the negate logic. However, I would only want to use this flow when I'm using something that uses an audio profile. I.e., I've been known to connect a keyboard and a mouse to my phone via Bluetooth to do some word-processing in a pinch. I wouldn't want those to disconnect my watch.
Additionally, I have the issue that if I don't have the final "connect" action to the audio device I'm connecting, it doesn't always connect to the phone after I disconnect the watch, which is why I was thinking about storing it in a variable and using that variable to connect back.
I will, however, take a look at the other. I'm still new enough to Automagic that it doesn't entirely make sense to me (yet), but I'll look at it.
Thanks.
Additionally, I have the issue that if I don't have the final "connect" action to the audio device I'm connecting, it doesn't always connect to the phone after I disconnect the watch, which is why I was thinking about storing it in a variable and using that variable to connect back.
I will, however, take a look at the other. I'm still new enough to Automagic that it doesn't entirely make sense to me (yet), but I'll look at it.
Thanks.
Re: Store Connecting Bluetooth Device in Variable
You can filter out the device using audio profile by another condition right after the trigger (and before Condition : Bluetooth device connected: Gear S3). Use Bluetooth device connected - any device - profile Headset.
If true, then continue to the Bluetooth device connected: Gear S3, false do nothing. So if you connect keyboard, the flow stop at here, never disconnect your Gear S3.
If the disconnect-reconnect have some issue, try to add some sleep in between. Sometimes, switching the connection can take up to 1-2 seconds.
If true, then continue to the Bluetooth device connected: Gear S3, false do nothing. So if you connect keyboard, the flow stop at here, never disconnect your Gear S3.
If the disconnect-reconnect have some issue, try to add some sleep in between. Sometimes, switching the connection can take up to 1-2 seconds.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Store Connecting Bluetooth Device in Variable
Huh. Never knew I could do that. Thanks.Desmanto wrote:You can filter out the device using audio profile by another condition right after the trigger (and before Condition : Bluetooth device connected: Gear S3). Use Bluetooth device connected - any device - profile Headset.