Auto enable Bluetooth when in vehicle

Butterfly_Joe

New member
Hello,

I put together two scripts to enable Bluetooth when MacroDroid senses movement in a vehicle. It also disables it, when my mobile disconnects from my vehicle (turning the vehicle off).

I tested the first one and it worked. But then I put together a different version.

I'm not sure which is 'better' or more efficient. What is everyone's thought?

Thank you
 

Attachments

  • Screenshot_20230320-195820.png
    Screenshot_20230320-195820.png
    148.4 KB · Views: 21
  • Screenshot_20230320-195836.png
    Screenshot_20230320-195836.png
    135.6 KB · Views: 21

Dm114

Well-known member
Hello,

I put together two scripts to enable Bluetooth when MacroDroid senses movement in a vehicle. It also disables it, when my mobile disconnects from my vehicle (turning the vehicle off).

I tested the first one and it worked. But then I put together a different version.

I'm not sure which is 'better' or more efficient. What is everyone's thought?

Thank you
As you only have 1 action in each case (enable/disable) both ways are equivalent in terms of "efficiency".

I personally would prefer the 2nd form (with constraints): it's "clearer"... In the 1st form I would replace the 2nd If...Endif by Elseif.

With Elseif it would be a bit more efficient because if 1st Condition is true, it won't check Elseif condition.
 

Endercraft

Moderator (& bug finder :D)
As you only have 1 action in each case (enable/disable) both ways are equivalent in terms of "efficiency".

I personally would prefer the 2nd form (with constraints): it's "clearer"... In the 1st form I would replace the 2nd If...Endif by Elseif.

With Elseif it would be a bit more efficient because if 1st Condition is true, it won't check Elseif condition.
Because MacroDroid puts a small delay between actions (I think this is the case) your else if proposition (is this word French or English...) is better if the smallest of smallest execution time is required. But else it doesn't really matter. But it's still an improvement after all.
 

Butterfly_Joe

New member
Thank you!

So, just using the second form (triggers firing) might be best?

Also, is the attached image what you were suggesting?

Thanks!
 

Attachments

  • Screenshot_20230321-122616.png
    Screenshot_20230321-122616.png
    156.4 KB · Views: 10

Dm114

Well-known member
Thank you!

So, just using the second form (triggers firing) might be best?

Also, is the attached image what you were suggesting?

Thanks!
To be perfectionist, I would test in 1st position the only condition that leads to Disable action and the double condition in 2nd position with the Elseif option.

This way, if the 1st (unique) condition happens to be true, it'll be tested faster that if it were a double condition.

But, don't worry, any of these solutions won't change anything in terms of speed on such a simple and short macro.
 

Butterfly_Joe

New member
Sorry, but I'm not sure I follow. Can you post the example/suggestion? (I'm also a perfectionist, at heart)

Like this?

Also, the way this is set up, will MacroDroid constantly trigger if it believes I am in a moving vehicle? Not sure if there is any way around that. Maybe have it not trigger if my mobile is connected to "Sakura"?
 

Attachments

  • Screenshot_20230321-183607.png
    Screenshot_20230321-183607.png
    133.9 KB · Views: 9
Last edited:

Dm114

Well-known member
Sorry, but I'm not sure I follow. Can you post the example/suggestion? (I'm also a perfectionist, at heart)

Like this?

Also, the way this is set up, will MacroDroid constantly trigger if it believes I am in a moving vehicle? Not sure if there is any way around that. Maybe have it not trigger if my mobile is connected to "Sakura"?
It's quite correct. But, as you only have 2 triggers you could only use one condition (BT disabled) in the Elseif clause because if the 1st condition is false (Device disconnected) , you are sure the 2nd one is true (Activity...) if you have no other mean to run this macro.

Then I would say that you even must not test whether BT is disabled (and replace Elseif by Else) because you can execute BT enabled action with no harm, even if it's already enabled...
 
Top