Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

give Google Assistant device commands programmatically

Is it possible to give Google Assistant commands programmatically? For example, I'd like to be able to send a command as text "turn on the fan" and have GA react as if that was the spoken command. I would also accept sending a JSON request in whatever format needed (with device IDs or whatever the API needs).

My situation is I have a ceiling fan that is controlled by Google Assistant. I want to be able to control it programmatically. For example, some event happens and my code wants to turn the fan on. Is there any way my code can tell GA to turn on the fan?

I tried using the Google Assistant SDK. I can send it text like "what time is it?" and get back text and audio, eg "It is 11:00am". However, I have a test device called "washer" and if I send text "is the washer running?" I get back "Sorry, I didn't understand". If I speak the words into my phone, I get back "The washer is running".

Why can't the GA SDK interact with my device? The credentials I give to the GA SDK are the same I use for my SmartHomeApp that defines the "washer" device.

like image 365
NateS Avatar asked Sep 30 '21 09:09

NateS


People also ask

Can I create custom Google Assistant commands?

You can create your own commands for your Google Assistant with IFTTT. Learn about services and devices you can control. For example, if you say: "Hey Google, activate 'tell my friends I'm going sailing,'" then a status update is posted to your social network.

Can you automate Google Assistant?

How to set up Routines on Google Assistant. You can get to the Routines settings page by first opening Google Assistant on your Android device and clicking on the three-dot menu on the bottom-right.

Is there an API for Google Assistant?

The Google Assistant Service exposes a low level API that lets you directly manipulate the audio bytes of an Assistant request and response. Bindings for this API can be generated for languages like Node. js, Go, C++, Java for all platforms that support gRPC.


2 Answers

To do this, you can setup up a virtual Assistant device and then send commands to it. Check out Assistant Relay, which is a service that sets up a virtual Assistant device and exposes a REST API so you can send text commands to it, as if they were spoken.

Per the Documentation:

Simply send Assistant Relay any query you would normally send Google Assistant, and Assistant Relay will call the Assistant SDK an execute your command.

Per the problem you are having with the Google Assistant SDK, I believe what you are trying to achieve is only possible with a device, be it physical or virtual and not by using the SDK directly.

like image 177
Brady Holt Avatar answered Oct 26 '22 21:10

Brady Holt


There are a lot of firewall and security issues allowing each smart device to to connect to the Internet. To alleviate this problem, Google's design methodology uses a fulfillment device as a bridge to connect to the device locally from one of their devices.

You are locally, on your smartphone, hooking into Google Assistant.
The phone is the fulfillment glue for the "washer" device.

According to this page:

Google Home or Google Nest device is required to perform the fulfillment.

Due to the portable nature of cell phones, it does not make sense to allow one to be used as the fulfillment device remotely, hence the local hook.

like image 30
Strom Avatar answered Oct 26 '22 21:10

Strom