Run a Google Routine
-
Ia am trying to run a Google Routine the same way that we can run Alexa Routines, but when I am creating the Routine I can't use de TriggerCMD command as an activator, I can see it in my device list, but it doesn't show on the valid devices to use as an Activator.
I want to do the same you did with de Lamp example (https://www.youtube.com/watch?v=nrqj-OwDpGE), but with Google Routines, how can this be done please??
-
@Marcos-Raldes,
unfortunately Google Assistant does not offer the ability to activate a routine when something like a doorbell button is pressed. Alexa does, and that's why you're able to run an Alexa routine when one of your TRIGGERcmd commands is triggered.<- Correction, I was wrong about this. You can create routines but you have to use the script editor. See post below.That said, you could run a routine from a python script on your computer if you wanted. I asked the AI Script Assistant to generate a script to do that. This is what it gave me:
AI Prompt: python script on Windows to run a google assistant routine
To run a Google Assistant routine on Windows using Python, you can use the google-auth and google-assistant-sdk libraries. Here’s an example script:
import os import json import google.auth.credentials from google.assistant.library import Assistant from google.assistant.library.event import EventType from google.assistant.library.file_helpers import existing_file # Set the path to your credentials file credentials_file = 'path/to/credentials.json' # Load the credentials from the file with open(credentials_file, 'r') as f: credentials = google.auth.credentials.Credentials.from_authorized_user_info(json.load(f)) # Define the routine you want to run routine = 'Good morning' # Create an Assistant instance with Assistant(credentials) as assistant: # Start the conversation assistant.start_conversation() # Send a text query to trigger the routine response = assistant.send_text_query(routine) # Print the response print(response)
Make sure to replace path/to/credentials.json with the actual path to your credentials file. You can create a credentials file by following the instructions in the Google Assistant SDK documentation.
To run the script, open a command prompt or PowerShell window and navigate to the directory where the script is saved. Then, run the command python script_name.py, replacing script_name.py with the actual name of your script file.
-
@Russ Thank you very much for your quick response!!
Google Assistant actually offers that ability, I have many routines triggered when a light or a Smartplug turns on, that's why I am trying to do this. There must be something that is missing from the Object that the TriggerCMD Command creates for the GA to recognice, maybe you can inquire about it, I am sure many other users will find it very usefull.
In the meantime I will have to learn the basics of Phyton as a workarround.
Thaks again!! Hope that you find the solution to this
-
@Marcos-Raldes, sorry you're right - I see that now. I'm still not sure why the TRIGGERcmd devices don't show up in Home app as a routine (aka Automation) starter option, but you can create routines that work with TRIGGERcmd using Google's script editor, then after it's created you can edit it in the Home app.
I made this video to demonstrate it: https://youtu.be/aP3FAuh291s
Here's my test routine that works for me:
The editor makes it easy to select your devices. You just start typing the name and it brings up a list of your devices that contain those letters.
Your TRIGGERcmd commands will only show up as Google devices if they have the voice field filled in. The computer also needs the voice field filled in, unless it's your default computer (set in your profile).
You'll also need to add your command's Google device to a home and a room before it will work. Long-press the device, then tap the gear in the upper-right, then tap Home (Add to a home).
Notice you specify whether the routine should run when the TRIGGERcmd device is flipped on or off. That's different from Alexa where triggering a command is like a doorbell press that runs the routine.
The state defaults to on unless you send off as the parameter, so you can run Google routines without having to send a parameter when you trigger your commands.
You can also create a routine (aka Automation) that triggers a command. You can use TRIGGERcmd device as a starter or an action but either way, you have to use the script editor to create the routine, not the Google Home app on your phone.
-