[Tasker Tips & Tricks] drum200910:
Send voice commands that you speak into the Gear S2 and have them transmit to your phone to run tasker tasks!

I made a youtube video of how it works : https://www.youtube.com/watch?v=SrXLeuY4sIc

I recently switched from a Pebble Time Round to a Gear S2. Pebble was very easy to run tasker apps from the watch including voice commands. Now with the Gear S2 it's a different story with the Tizen OS - not much support for this. I've seen some requests made to joaomgcd as he's done some amazing stuff for Tasker but the Tizen watches are too expensive for him to develop on.

I was trying to find a way to send voice commands that I spoke into the Gear S2 and have them transmit to my phone to run tasker tasks. I searched high and low and see that there are may others trying to so the same thing. There is the TaskS2 that lets you press the screen on the phone to run tasker apps which is good but doesn't capture text. So I came up with a work-around to be able to speak into the watch and have it run tasker tasks on the phone using the text that I spoke into the watch

**How it works once you have everything setup:**

1) The Gear S2 with the command "text" will send text info to a contact. So to get our text we will create a dummy contact.

2) Define a wake up command on the Gear S2 such as "OK Google". With your screen ready say to the watch "OK Google"

3) When the prompt comes up, say to the watch something like "Text Samsung task to deposit cheque at bank"

What this does is it recognizes the 'Text' command as sending a SMS text message to a contact called "Samsung" (which is a dummy contact). When the confirmation then it shows you the text on the watch, say "OK"

4) It then will send your phone an outgoing text message to the contact "Samsung" with the text as "task to deposit cheque at bank". The word "text" gets dropped as it's the command and "Samsung" gets dropped as it's the dummy contact it sends the message to

5) Now the contact on your phone "Samsung" has one text message with the message "Text Samsung task to deposit cheque at bank" - Yay! we now have useable text that we spoke into our Gear S2 and through the magic of bluetooth is now on our phone and we can use as a cliboard variable in tasker!

6) Macro Droid is then triggered by the fact that an outgoing sms event occurred that you told it to monitor the specific contact "Samsung". From here an action in MacroDroid is used to call a tasker task (Macro driod can use LOCALE/Tasker plugins - I used Secure settings - tasker shortcut). The tasker task then extracts the text from the Samsung contact, copies it to clipboard, deletes the outgoing text message so it's fresh for another new message, and can then other tasker steps with the text now in the clipboard.

The hardest thing I found was trying to capture the outgoing sms event as a trigger as tasker only deals with it's own "SMS sent successful" - it doesn't capture any broadcast receiver intent or ContentObserver from the SMS application on the phone and therefore no trigger once the text has been sent out. That's where after trial and error with some apps, I stumbled upon MacroDroid. This is what closed the loop on the solution - where it monitors that text being sent out by the dummy contact and it works very well for this.

**Requirements:**

-Tasker

-AutoInput tasker plugin - to simulate screen clicks and type in info)

-Macro Droid - to capture the event of sms sent when a dummy contact is used and trigger the tasker tasks

Optional

-Secure settings tasker plugin - for 'clear password' to turn screen on if you want, also for Macro Droid to run a tasker shortcut

**Steps:**

1) Create a dummy contact. I used "Samsung" as my contact name. Give it a dummy 10 digit phone number with a valid area code. I used (416)000-0000

2) Create your tasker tasks

Task 1: using Autoinput: launch contacts, lookup contact samsung, press the sms icon, long click on the message that the Gear S2 sent, copy to clipboard, delete the message - task done - you now have the text in a variable called %CLIP. At the end of this task call the next task

Task 2: now that you have the text the %CLIP variable, you can set a new variable and copy to say %CLIP1 and search and replace and remove any text you don't need. For example: "task to deposit cheque at bank" can be massaged using variable search and replace to something like "to deposit cheque at bank". In this task you can create if, else, then statements. For example:

a) "Text Samsung task to deposit cheque at bank" - if %CLIP matches reggex keyword .*task*. then run a task such as a reminder application like DGT

b) "Text Samsung drive to work" if %CLIP = keyword "drive to work" then run a task such as launching a shortcut for google maps or waze

Task 3: if needed, you can then run some clean up tasks like to close the contact & message app so it's not open in the back ground. I use 1) Go Home 2) Run Shell input keyevent 187 3) wait 1 second 4) AutoInput Action: Close all Action

3) Create a Macro in Macro droid 1) Trigger "SMS Sent to Contact" - specify contact as "Samsung" and SMS text "Any" . 2) action Locale/ Tasker plugin - Secure Settings - Execute Shortcut - choose the tasker task that you want to then run from step 2

**Here are the 2 tasker tasks:**

**1st) to deal with the capturing text on dummy contact:**

A1: Secure Settings [ Configuration:Clear Password Timeout (Seconds):0 ]

A2: Launch App [ App:Contacts Data: Exclude From Recent Apps:eek:ff Always Start New Copy:eek:ff ]

A3: AutoInput Action [ Configuration:Type: Text

Value: Search

Action : Click

Is Tasker Action: false

Check Screen State: false Timeout (Seconds):20 ]

A4: AutoInput Action [ Configuration:Type: Text

Value: Search

Text to Write : samsung

Action : Write

Is Tasker Action: false

Check Screen State: false Timeout (Seconds):20 ]

A5: AutoInput Action [ Configuration:Type: Id

Value: com.android.contacts:id/cliv_name_textview

Action : Click

Is Tasker Action: false

Check Screen State: false Timeout (Seconds):20 ]

A6: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]

A7: AutoInput Action [ Configuration:Type: Text

Value: Send message

Action : Click

Is Tasker Action: false

Check Screen State: false Timeout (Seconds):20 ]

A8: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]

A9: AutoInput Action [ Configuration:Type: Point

Value: 1292,582

Action : Long Click

Is Tasker Action: true

Check Screen State: false Timeout (Seconds):20 ]

A10: AutoInput Action [ Configuration:Type: Text

Value: Copy text

Action : Click

Is Tasker Action: false

Check Screen State: false Timeout (Seconds):20 ]

A11: AutoInput Action [ Configuration:Type: Text

Value: More

Action : Click

Is Tasker Action: false

Check Screen State: false Timeout (Seconds):20 ]

A12: AutoInput Action [ Configuration:Type: Text

Value: Delete

Action : Click

Is Tasker Action: false

Check Screen State: false Timeout (Seconds):20 ]

A13: AutoInput Action [ Configuration:Type: Text

Value: All

Action : Click

Is Tasker Action: false

Check Screen State: false Timeout (Seconds):20 ]

A14: AutoInput Action [ Configuration:Type: Text

Value: Delete

Action : Click

Is Tasker Action: false

Check Screen State: false Timeout (Seconds):20 ]

A15: AutoInput Action [ Configuration:Type: Text

Value: Delete

Action : Click

Is Tasker Action: false

Check Screen State: false Timeout (Seconds):20 ]

A16: Variable Set [ Name:%CLIP1 To:%CLIP Recurse Variables:eek:ff Do Maths:eek:ff Append:eek:ff ]

A17: Perform Task [ Name:GR If Cond Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:eek:ff ]

**2nd) task to run IF statements based on keyword**

A1: Flash [ Text:%CLIP Long:eek:ff ]

A2: If [ %CLIP ~R .*tomorrow.*Task.*|.*Task.*tomorrow.* ]

A3: Perform Task [ Name:TV GTD remindr tomor Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:eek:ff ]

A4: Else If [ %CLIP ~R .*Task.* ]

A5: Perform Task [ Name:TV GTD remindr Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:eek:ff ]

A6: Else If [ %CLIP eq Drive to work ]

A7: Perform Task [ Name:Wazewk Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:eek:ff ]

A8: Else If [ %CLIP eq Drive to home ]

A9: Perform Task [ Name:Wazehm Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:eek:ff ]

A10: Else If [ %CLIP ~R .*Text.* ]

A11: Perform Task [ Name:TV Type Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:eek:ff ]

A12: End If