How to trigger when in power wireless AND activity in véhicule ?

Christoph

Member
Hi, I have an old car from the end of the 90. It doesn't have Bluetooth, so to automatically start Google Maps I can not use Bluetooth like most people. Instead I can use a trigger so that it starts when smartphone is wirelessly powered (as I have installed a wireless charger in the car). But I need also to check the activity is in vehicule (with a very large accepting range is enough) otherwise Google Maps will start when I charge it at home. As there is no possibility to add an activity constraint on Power Connected trigger, I have used a If clause:
1680341372765.png
But it does not work: when wirelessly powered and using my phone the app is not being launched. So what would be the right trigger in my situation? Regards
 

Dm114

Well-known member
Hi, I have an old car from the end of the 90. It doesn't have Bluetooth, so to automatically start Google Maps I can not use Bluetooth like most people. Instead I can use a trigger so that it starts when smartphone is wirelessly powered (as I have installed a wireless charger in the car). But I need also to check the activity is in vehicule (with a very large accepting range is enough) otherwise Google Maps will start when I charge it at home. As there is no possibility to add an activity constraint on Power Connected trigger, I have used a If clause:
View attachment 5132
But it does not work: when wirelessly powered and using my phone the app is not being launched. So what would be the right trigger in my situation? Regards
Don't add any constraint on them otherwise it won't fire as triggers only fire once, at the exact time the described event occurs. Generally several triggers never fire at the same time but one after the other, like in your case, depending on which event occurs first.

Thus your If statement is not correct because both triggers cannot fire at the same time! Instead of testing an event (trigger), test a status (connection type and activity).
 

Dm114

Well-known member
As you cannot test an activity status, set a boolean variable when the trigger fires instead (like InVehicle=True/False).
 

Qarboz

Well-known member
Or you can use the "Vehicle" activity as a trigger and insert the "Wireless charge" constraint. However, to work properly, it is important that the phone is connected to wireless charging before the car moves
 

Dm114

Well-known member
Or you can use the "Vehicle" activity as a trigger and insert the "Wireless charge" constraint. However, to work properly, it is important that the phone is connected to wireless charging before the car moves
You're right otherwise he will miss the opportunity of running the macro. It's the reason why I suggested to test status at the time each trigger fires rather than trigger firing.
 

Christoph

Member
Thank you, I understand, triggers will not come together. In real life there is no order between starting to run the car and plugging the phone to wireless power.

I have modified is like this:

  • Macro when I am in my car:
1680369096437.png

  • Macro when I am leaving my car:
1680369202007.png
I have used a global boolean variable to know I was in the car, otherwise the leaving car macro would start without even being in the car, but there is still an issue: this leaving macro will be triggered too many times in a day even if I do not use a car. Is there a way to avoid this ?
 

Dm114

Well-known member
Thank you, I understand, triggers will not come together. In real life there is no order between starting to run the car and plugging the phone to wireless power.

I have modified is like this:

  • Macro when I am in my car:
View attachment 5134

  • Macro when I am leaving my car:
View attachment 5135
I have used a global boolean variable to know I was in the car, otherwise the leaving car macro would start without even being in the car, but there is still an issue: this leaving macro will be triggered too many times in a day even if I do not use a car. Is there a way to avoid this ?
Your 2nd macro is not correct: when Power connected trigger fires, power is already connected so your Power disconnected constraint prevents trigger from firing!

To make things simpler, I would make a 1st macro managing the Activity sensor i.e. setting your boolean variable True/False according to the activity detected (InCar = True, all other activities = False). To avoid triggering to often, the other acitivity triggers should be constrained by InCar=True. This variable could also be replaced by the special MD Mode which is a kind of integrated global string variable (you could define various MD Modes such as 🚘 or🚶or🏃...).

Then, the triggers of your 2nd macro will fire when power is connected (with contraint InCar=True or Mode=🚘) or when power is disconnected.
 

Christoph

Member
So the 1st trigger of my 2nd macro with the constraint has sense, make sense now.

I haven't thought about MD mode, because I have never used it, but it looks good. What is the difference between this and a global variable?

So in the end I need 3 macros:
- a macro to manage the mode
- a macro with trigger mode car starting to open Google Maps etc
- a macro with trigger mode car ended to close Google Maps
 

Dm114

Well-known member
So the 1st trigger of my 2nd macro with the constraint has sense, make sense now.

I haven't thought about MD mode, because I have never used it, but it looks good. What is the difference between this and a global variable?

So in the end I need 3 macros:
- a macro to manage the mode
- a macro with trigger mode car starting to open Google Maps etc
- a macro with trigger mode car ended to close Google Maps
MD Mode acts a bit like a Global string variable and can be used anywhere in MD. Its values are set in MD Menu > Settings > MacroDroid Modes

Macro1:
T1: Activity In vehicle
T2: Activity On bicycle
C:InCar=True (or MD Mode=🚘)​
T3: Activity Running
C:InCar=True (or MD Mode=🚘)​
T4: Activity Walking
C:InCar=True (or MD Mode=🚘)​
T5: Activity Still
C:InCar=True (or MD Mode=🚘)​
A: If T1 fired → InCar=True (or MD Mode=🚘)
A: Else → InCar=False (to use MD Mode, either use a unique value for "Not In Car", or 1 Else If statement per activity with the appropriate value)

Macro 2:
T1: Power connected wireless
C:InCar=True (or MD Mode=🚘)​
T2: Power connected other means
C:InCar=True (or MD Mode=🚘)​
T3: Power disconnected
C:InCar=True (or MD Mode=🚘)​
T4: Any change in variable InCar (or MD Mode)
A: If Power connected wireless AND InCar=True (or MD Mode=🚘) → Launch Google Maps...
A: Else → Close Google Maps...

Hope it'll help but be careful with the poor accuracy of the Activity Sensor.

I couldn't test these macros but they should work as intended... 😃
 

Dm114

Well-known member
I guess you understood that, in macros:
Tⁿ: stands for Triggerⁿ
C: stands for Constraint
A: stands Action
 
Top