Page 1 of 1

Newbie Triggers and Conditions Question

Posted: 30 Mar 2016 18:11
by homemadehitshow
So I see that if I set two triggers they are OR.

But I am struggling to find an equivalent condition to match some of things I want.

Example is that I have a flow that is intended to auto reply to texts while driving. My triggers are

Driving (Activity) OR SMS Received

It works great when I am driving and receive a SMS

However what I found is that when I am driving but no SMS comes in the flow fires off but fails due to the lack of incoming SMS

So what I need is a single trigger (either SMS recieved or Driving) then a condition. Since I know the Activity Experimental isn't designed to run as a condition then I need

* Driving
* SMS Received Condition

But I cannot figure out an SMS received condition.

I may be overlooking something obvious and there may be a completely different way to do this but I'd appreciate some guidance.

Re: Newbie Triggers and Conditions Question

Posted: 30 Mar 2016 19:07
by Martin
Hi,

Triggers in Automagic are always executed by an event or a state change so the triggers are not 'active' over a longer period of time hence it's not possible to combine two triggers with an AND operation. Checks for a state that lasts longer can often be checked with a condition. Unfortunately 'User Activity' is not available as a condition since it could take a long time to let the device determine the current user activity and the API provided by Google does not match this use case well.

You could work around this limitation by remembering if you are driving with a flow that triggers on User Activity: In vehicle/begin and executes action Script: global_vehicle = true;
and another flow that resets the value: trigger User Activity: In vehicle/end --> Script: global_vehicle = false;

You can now check the global variable when an SMS is received:
-trigger SMS Received
-condition Expression: global_vehicle
--> true: -action when SMS is received while driving
--> false: -action when SMS is received while NOT driving

The user activity is marked as experimental since it relies on Google Play services to detect the current user activity and detection might not be totally reliable. It's usually more reliable to use a condition Bluetooth Device Connected: <your car> when you use bluetooth in your car so the flow could be changed to this:
-trigger SMS Received
-condition Bluetoth Device Connected: <your car>
--> true: -action when SMS is received when in car
--> false: -action when SMS is received when NOT in car

Regards,
Martin

Re: Newbie Triggers and Conditions Question

Posted: 30 Mar 2016 21:01
by homemadehitshow
Thanks. My problem with the Bluetooth trigger is that I use both my car bluetooth and sometimes some headphones when I drive the carpool. I also use those headphones when not driving. So then I would need a way to know driving and connected to those headphones (P311) and when using the P311's without driving.

It's all good fun though :)