简体   繁体   English

Google上的Google Assistant操作

[英]Google Assistant actions on google

All my hardware is already developed. 我所有的硬件均已开发。 I use MQTT for communication between my devices, I have lights, fans, heaters and many more ioT appliances. 我使用MQTT在我的设备之间进行通信,我有灯,风扇,加热器和许多ioT设备。 I can controll all of these from my Android application which i have built. 我可以从自己构建的Android应用程序中控制所有这些。 I would like to use Google Assistant to control my devices as well. 我也想使用Google Assistant来控制我的设备。 The status of my lights (on/off) are stored in a sql database and when ever a change occurs to the database(detected by the hardware) my hardware can control that specific light. 我的灯光状态(开/关)存储在sql数据库中,并且一旦数据库发生更改(由硬件检测到),我的硬件就可以控制该特定的灯光。 In My Android app i do the same thing which is updating the databases value(on/off) of the light and the change is detected by my hardware platform. 在我的Android应用程序中,我做同样的事情,即更新灯光的数据库值(开/关),并且该更改被我的硬件平台检测到。 Can i use Google Assistant to update a sql database value? 我可以使用Google Assistant更新sql数据库值吗? I can create a webserver( ASP.NET C#) and pass the command to the sql database of my relevant customer if google assistant can invoke the username or email, lightID, command to my webserver. 我可以创建一个Web服务器(ASP.NET C#)并将该命令传递给相关客户的sql数据库,如果Google Assistant可以将用户名或电子邮件,lightID命令调用给我的Web服务器。 Can google assistant do this? Google Assistant可以这样做吗? If not how would achieve this. 如果没有,将如何实现这一目标。

It sounds like you want to take a look at the Actions on Google Smart Home API which will let the Assistants Smart Home controls work with your control server directly. 听起来您好像想看看Google Smart Home API上的操作,它将使Assistants Smart Home控件直接与您的控制服务器一起使用。

Without knowing exactly how your database or existing web server are configured or hosted, I can speak only broadly at best. 在不确切了解数据库或现有Web服务器如何配置或托管的情况下,我充其量只能讲最多。 Your web server will need to implement two primary things: 您的Web服务器将需要实现两个主要方面:

  1. You'll need an OAuth2 server that can issue tokens that represent your users. 您将需要一个OAuth2服务器,该服务器可以发出代表您的用户的令牌。 This is how Google will associate the user's account on the Assistant with your account, and how Google will identify (to you) which user is issuing the command. 这就是Google如何将Assistant上的用户帐户与您的帐户相关联,以及Google如何识别(向您)发出该命令的用户。

  2. You will need to implement a webhook at a URL on your web server. 您将需要在Web服务器上的URL上实现Webhook。 This webhook will be sent a POST message containing a header with a valid auth token (that you issued) and a JSON body. 将向此Webhook发送POST消息,该消息包含带有有效auth令牌(已发出)的标头和JSON正文。 The JSON will contain information about the command that has been issued by the user. JSON将包含有关用户已发出的命令的信息。 Your HTTP reply body will also be JSON. 您的HTTP回复正文也将为JSON。 For details of the JSON formats and all the fields that it can send and that you must reply with, consult Google's documentation. 有关JSON格式及其可以发送的所有字段以及您必须回复的所有字段的详细信息,请查阅Google的文档。

There are a number of different commands (which Google calls "intents") that Google can send you on behalf of the user. Google可以代表用户向您发送许多不同的命令(Google称之为“意图”)。 You should be able to handle all of them by either querying or modifying your database: 您应该能够通过查询或修改数据库来处理所有这些问题:

  • SYNC - A request for what devices this user has, some of their configuration information, and what commands they respect. SYNC-请求此用户拥有哪些设备,一些配置信息以及他们遵循的命令。
  • QUERY - What is the current state of the devices for this user. 查询 -该用户当前设备​​的状态是什么。
  • EXECUTE - Change the state on some of the user's devices. 执行 -更改某些用户设备上的状态。
  • RESYNC - (Future update) A re-request of the user's device info. 重新同步 -(未来更新)重新请求用户的设备信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM