A while back I made a project that basically steals the Google assistant command so you could get any command given to the assistant into Tasker. This only works on the device that you spoke the command into. It can be found here.
This project will now allow you to use any device including the Google home speaker to get the commands into Tasker. It requires using a dedicated android device to continually monitor for a logcat event and then steal the command from your Google assistant activity web page.
I found that any time you issue a command to the assistant it will send a push to all other devices connected to your assistant. I assume this might be the way it handles when multiple devices hear the same ok google command so they can say "answering on another device. This puts a entry in the logcat. So I simply monitor for that then open the assistant activity page and steal the command with autoinput.
Using autoinput to get the last assistant activity is not the best approach so hopefully someone will be able to figure out how to get the info with a http request. This will make things far more efficient. Any help with that would be greatly appreciated.
Unfortunately this same entry shows up approx every 30 min even when there has been no activity with the assistant. So I need to test the activity page for every one of these entries to test if it was a activity that triggered it. I have done this with multiple variable splits that gets the fist activity on the web page and tests the time of the activity from the web page against the current time to see if the command was just issued.
This is still a work in progress and pretty much a proof of concept. I am currently leaving the web page open and then issue a autoweb command to refresh it. I use a black scene to prevent any screen burn. . Here is the log cat entry. You will of course need to find the one that is specific to your device
1613790301.826 2182 2182 W GCM : broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.google.android.googlequicksearchbox (has extras) }
Edit. I found in testing if I only have 2 devices linked to the assistant then only one of them will receive this logcat event. When I linked my home speaker then both of my other devices showed the logcat entry. In other words it acts like a master slave set up. Google picks the device to be the master wich will answer the command so the slave gets the push. If you issue a command to the slave the master will not receive the push. However if there is a third device like the home speaker then that will now be the master so both of the other slave devices will now receive the push. This all works even when the devices are not close to each other. So long story short, your home device for monitoring needs to be a slave device.
Here is the current project.
Profile: Get Logs (990)
Cooldown: 3 Restore: no
Event: Logcat Entry [ Output Variables:* Component:GCM Filter:broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.google.android.googlequicksearchbox (has extras) } Grep Filter (Check Help):Off ]
Enter: Assist Logs (991)
A1: Destroy Scene [ Name:Screen Black Continue Task After Error:On ]
A2: Variable Set [ Name:%times To:%TIMES Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
<Put your assistant web address here.>
A3: AutoTools Web Screen [ Configuration:Display Mode: Normal
Source: Your assistant activity web address here
Toast Duration: 5000
Height: 400
Gravity: Center
Animation: Slide In From Top
Show Duration: 500
Hide Duration: 250
Get HTML: true Timeout (Seconds):30 ]
A4: Wait [ MS:0 Seconds:7 Minutes:0 Hours:0 Days:0 ]
A5: AutoInput UI Query [ Configuration: Timeout (Seconds):20 ]
A6: [X] Write File [ File:Assist web info.txt Text:%aitext()
****************************************** Append:On Add Newline:On ]
<Set Time and set AM / PM>
A7: Anchor
A8: Variable Convert [ Name:%times Function:Seconds to Long Date Time Store Result In:%current_time Mode:Default ]
A9: Variable Split [ Name:%current_time Splitter: Delete Base:Off ]
A10: Variable Section [ Name:%current_time5 From:6 Length:2 Adapt To Fit:Off Store Result In:%am_pm ]
A11: Variable Section [ Name:%current_time5 From:1 Length:5 Adapt To Fit:Off Store Result In:%trimmed_time ]
A12: Variable Search Replace [ Variable:%trimmed_time Search:: Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In Array: Replace Matches:On Replace With:. ]
<Set data and split data at beginning of list>
A13: Variable Set [ Name:%data To:%aitext() Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
A14: Variable Split [ Name:%data Splitter:Today,Delete all activity from Delete Base:Off Continue Task After Error:On ]
A15: Goto [ Type:Action Label Number:1 Label:Error ] If [ %err Set ]
<Test if activity at top of list is am or pm>
A16: Anchor
A17: Variable Set [ Name:%am_data To:%data2 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
A18: Variable Set [ Name:%pm_data To:%data2 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
A19: Variable Split [ Name:%am_data Splitter:AM • Delete Base:Off Continue Task After Error:On ]
A20: Variable Split [ Name:%am_data1 Splitter:, Delete Base:Off Continue Task After Error:On ]
A21: Variable Split [ Name:%pm_data Splitter:PM • Delete Base:Off Continue Task After Error:On ]
A22: Variable Split [ Name:%pm_data1 Splitter:, Delete Base:Off Continue Task After Error:On ]
A23: Goto [ Type:Action Label Number:1 Label:Error ] If [ %err Set ]
A24: If [ %am_data1(#) < %pm_data1(#) ]
A25: Goto [ Type:Action Label Number:1 Label:End ] If [ %am_pm ~ PM ]
A26: Variable Set [ Name:%last_entry To:%am_data1 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
A27: End If
A28: If [ %am_data1(#) > %pm_data1(#) ]
A29: Goto [ Type:Action Label Number:1 Label:End ] If [ %am_pm ~ AM ]
A30: Variable Set [ Name:%last_entry To:%pm_data1 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
A31: End If
A32: Variable Split [ Name:%last_entry Splitter:Said , Delete Base:Off Continue Task After Error:On ]
A33: Variable Split [ Name:%last_entry2 Splitter:, Delete Base:Off Continue Task After Error:On ]
A34: Goto [ Type:Action Label Number:1 Label:End ] If [ %err Set ]
<Get Time in first activity on list>
A35: Anchor
A36: Variable Set [ Name:%command_time To:%last_entry2(<) Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
A37: Variable Search Replace [ Variable:%command_time Search:: Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In Array: Replace Matches:On Replace With:. ]
A38: Variable Set [ Name:%time_diff To:abs(%trimmed_time - %command_time) Recurse Variables:Off Do Maths:On Append:Off Max Rounding Digits:3 ]
<Check for more than 4 minutes in between trigger time and command time>
A39: Goto [ Type:Action Label Number:1 Label:End ] If [ %time_diff > .04 ]
A40: Flash [ Text:%last_entry21 Long:On ]
A41: Notify [ Title:Get Logs %TIMES%command_time Text:%last_entry21 %TIME CT-%command_time Icon:null Number:0 Permanent:Off Priority:3 Repeat Alert:Off LED Colour:Red LED Rate:0 Sound File: Vibration Pattern: Category: ]
<End>
A42: Anchor
A43: Write File [ File:Assist web info.txt Text:End - %TIME
Diff - %time_diff
Last entry - %last_entry
Logcat - %lc_text
****************************************** Append:On Add Newline:On ]
A44: Wait [ MS:0 Seconds:4 Minutes:0 Hours:0 Days:0 ]
A45: Show Scene [ Name:Screen Black Display As:Activity, No Bar, No Status, No Nav Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:On Show Over Keyguard:On Continue Task Immediately:On ]
A46: Stop [ With Error:Off Task: ]
<Error>
A47: Anchor
A48: Write File [ File:Assist web info.txt Text:Error %TIME
Diff - %time_diff
Last entry - %last_entry
AI text - %aitext()
****************************************** Append:On Add Newline:On ]
A49: Notify [ Title:Error In Assist HTTP %TIMES Text:%TIME %data Icon:null Number:0 Permanent:Off Priority:3 Repeat Alert:Off LED Colour:Red LED Rate:0 Sound File: Vibration Pattern: Category: ]
A50: Flash [ Text:Error Long:On ]
A51: Wait [ MS:0 Seconds:4 Minutes:0 Hours:0 Days:0 ]
A52: Show Scene [ Name:Screen Black Display As:Activity, No Bar, No Status, No Nav Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:On Show Over Keyguard:On Continue Task Immediately:On ]
A53: Stop [ With Error:Off Task: ]
Known issues...
- Because it uses autoinput to retrieve the command it takes a few seconds to acquire the command.
- It requires a dedicated android device to monitor for the logcat and steal the command. ( I use a tablet that sits in the kitchen just showing pics )