Which Trigger Caused Macro to Run?

mdman2021

New member
Here's another easy puzzle -- provided there is an answer.

I have a single macro containing 5 TRIGGER's. In this macro, each of the 5 triggers is "Application Launched" but each one is for a different Application. If any one of the 5 triggers is tripped then the macro will run.

So, here's what I want to do... I would like to know which trigger caused the macro to run each time it runs. Is there a Macrodroid (MD) ACTION (like maybe an "if" clause?) that will tell me which of the 5 triggers caused this macro to run? I realize I could probably manually look in the System Log to find the answer BUT I want to automatically program for this using a Macrodroid Action. I also could create 5 separate macros with ONE trigger each but I don't want to maintain 5 separate macros since the macro merely sends me an SMS saying which Application was Launched.

So, any ideas?
 

Dm114

Well-known member
Here's another easy puzzle -- provided there is an answer.

I have a single macro containing 5 TRIGGER's. In this macro, each of the 5 triggers is "Application Launched" but each one is for a different Application. If any one of the 5 triggers is tripped then the macro will run.

So, here's what I want to do... I would like to know which trigger caused the macro to run each time it runs. Is there a Macrodroid (MD) ACTION (like maybe an "if" clause?) that will tell me which of the 5 triggers caused this macro to run? I realize I could probably manually look in the System Log to find the answer BUT I want to automatically program for this using a Macrodroid Action. I also could create 5 separate macros with ONE trigger each but I don't want to maintain 5 separate macros since the macro merely sends me an SMS saying which Application was Launched.

So, any ideas?
As @roughnecks says, use an 'If' and 'Else if' statements to test which trigger fired.
 

mdman2021

New member
Actually, @roughnecks comment was a little intimidating and DID NOT help. I only suspected that it could be done with an 'if' and could have spent hours (days?) digging for the answer which is why I decided to try the Macrodroid Forum.

It was @Dm114 that steered me in the right direction. Thank-you @Dm114 for confirming the trigger test could be done with an 'if'. When I built the 'if' I searched for "trigger" and the search found "Trigger Fired".

Others may find this additional explanation helpful... I wrote one 'if' for each of my five triggers. Any ONE of the five triggers could cause my macro to run. Here is just one of the five 'if' statements I wrote. The following 'if' will tell me my Macrodroid macro ran as a result of the trigger firing which checks to see if I have received any Gmail notifications from JetBlue airlines where the Gmail "Subject:" contains the text "JetBlue - Your Flight is Delayed".

If
Trigger Fired: Notification Received: Contains:
JetBlue - Your Flight is Delayed (Gmail)
Send SMS
[v=MyMobilePhoneNumber]: Email received from JetBlue. Check email.
End If

I wrote the code above, to use SMS to alert me to read my email because -- let's face it -- we all check our SMS messages far more often than our email.
 

Dm114

Well-known member
Actually, @roughnecks comment was a little intimidating and DID NOT help. I only suspected that it could be done with an 'if' and could have spent hours (days?) digging for the answer which is why I decided to try the Macrodroid Forum.

It was @Dm114 that steered me in the right direction. Thank-you @Dm114 for confirming the trigger test could be done with an 'if'. When I built the 'if' I searched for "trigger" and the search found "Trigger Fired".

Others may find this additional explanation helpful... I wrote one 'if' for each of my five triggers. Any ONE of the five triggers could cause my macro to run. Here is just one of the five 'if' statements I wrote. The following 'if' will tell me my Macrodroid macro ran as a result of the trigger firing which checks to see if I have received any Gmail notifications from JetBlue airlines where the Gmail "Subject:" contains the text "JetBlue - Your Flight is Delayed".

If
Trigger Fired: Notification Received: Contains:
JetBlue - Your Flight is Delayed (Gmail)
Send SMS
[v=MyMobilePhoneNumber]: Email received from JetBlue. Check email.
End If

I wrote the code above, to use SMS to alert me to read my email because -- let's face it -- we all check our SMS messages far more often than our email.
Thanks for your comments.

To improve the efficiency of your macro(s), you'd rather use only one 'IF... ELSEIF[...ELSEIF][...][...ELSE]...ENDIF' statement instead of multiple 'IF...ENDIF' statements.

Good luck!
 
Top