设备操作概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
借助 Google 助理 SDK,您可以将 Google 助理嵌入到自己的项目中,使其功能与 Google Home 类似。不过,您的项目可能具有 Google Home 所不具备的独特硬件功能:例如,它可能具有独特的 LED 显示屏,可自定义亮度和颜色设置。
设备操作是一组工具和 API,可让您在自己开发的项目中扩展 Google 助理的功能,以充分发挥硬件功能的潜力。
内置设备操作
Google 针对日常事务创建了各种常用的内置设备操作,包括灯具、电器和摄像头。借助这些操作,您可以利用 Google 助理的自然语言处理功能来控制项目。例如,带有灯的项目可以通过多种方式开启:
- Ok Google,开灯。
- Hey Google,开灯。
- Ok Google,打开客厅的灯。
您可以创建自己的项目,以响应许多智能家居特征
的指令,例如:
- Ok Google,将亮度设为 50%。
- Hey Google,将温度设为 98 度。
自定义设备操作
您还可以为自己的独特硬件创建自定义设备操作。对于这些操作,您需要定义语法和命令:
- Ok Google,让我的灯闪烁 5 次。
- Hey Google,向左移动。
详细了解如何通过 Google 助理服务纳入这些操作。
运作方式
设备上已安装 Google 助理 SDK,以及用于访问 Google 助理服务的凭据。设备发送语音请求(开启),并要求服务开启设备的板载 LED。
设备还会发送其型号和设备实例标识符,以便服务能够确定如何在上下文中以最佳方式响应请求。
该服务使用自动语音识别 (ASR) 来确定用户说出的字词,使用自然语言处理 (NLP) 来分析和理解这些字词所表达的请求的含义,并使用设备匹配来为请求提供上下文。此上下文非常重要,因为它定义了设备支持的操作以及应如何完成这些操作。
然后,该服务会返回一段文字,并将其读给用户听(好的。),同时还会返回特定于设备的命令。设备知道如何处理此命令:它会开启 LED!

开始使用
通过将 Google 助理嵌入到项目中,然后使用设备操作添加独特的功能,将您的创意变为现实。您可以使用 Google 助理服务开发项目。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThe Google Assistant SDK enables you to integrate the Google Assistant into your projects, similar to a Google Home, and leverage Device Actions to utilize unique hardware features.\u003c/p\u003e\n"],["\u003cp\u003eDevice Actions provide tools and APIs to extend the Assistant's capabilities, allowing your project to respond to voice commands for functionalities like lights, appliances, and cameras using built-in or custom actions.\u003c/p\u003e\n"],["\u003cp\u003eBuilt-in Device Actions cover common smart home features, while Custom Device Actions let you define unique voice commands and functionalities tailored to your specific hardware.\u003c/p\u003e\n"],["\u003cp\u003eThe Google Assistant service utilizes Automatic Speech Recognition, Natural Language Processing, and device context to understand user requests and trigger corresponding actions on your device.\u003c/p\u003e\n"],["\u003cp\u003eYou can get started by embedding the Google Assistant into your project and adding custom functionalities with Device Actions using the provided resources and guides.\u003c/p\u003e\n"]]],[],null,["# Device Actions Overview\n\nWith the Google Assistant SDK, you can embed the Google Assistant into your\nown project, making it function similarly to a Google Home. However, your project\nmay have unique hardware capabilities that Google Home does not have: for\nexample, it may have a unique LED display with customizable brightness and\ncolor settings.\n\nDevice Actions are a set of tools and APIs that allow you to extend what\nthe Assistant can do, in the projects you develop, to take full potential of\ntheir hardware capabilities.\n\nBuilt-in Device Actions\n-----------------------\n\nGoogle has created a wide range of common built-in device actions for everyday\nthings, including lights, appliances, and cameras. With these actions, you can\nharness the power of the Google Assistant's natural language processing to\ncontrol your project. For example, a project with a light can be turned on in\ndifferent ways:\n\n- *Ok Google, turn on the light.*\n- *Hey Google, turn my light on.*\n- *Ok Google, turn on my living room light.*\n\nYou can create your own project that responds to commands for\nmany\n[smart home traits](/assistant/sdk/reference/traits)\nlike:\n\n- *Ok Google, set the brightness to 50%.*\n- *Hey Google, set the temperature to 98 degrees.*\n\nCustom Device Actions\n---------------------\n\nYou can also create custom device actions for your own unique hardware. For these\nactions, you define the grammar and commands:\n\n- *Ok Google, blink my light 5 times.*\n- *Hey Google, move left.*\n\nLearn more about incorporating these actions using the [Google Assistant service](/assistant/sdk/guides/service/python/extend/custom-actions).\n\nHow it works\n------------\n\nThe device has the Google Assistant SDK installed on it along with credentials for\naccessing the Google Assistant Service. The device sends out the spoken request\n(*Turn on.*) and asks the service to turn on the device's onboard LED.\nThe device also sends its model and device instance identifiers so the service\ncan determine how to best respond in context to the request.\n\nThe service uses Automatic Speech Recognition (ASR) to determine what words were\nspoken by the user, Natural Language Processing (NLP) to analyze and understand\nthe meaning of the request from these words, and device matching to provide context\nfor the request. This context is important because it defines the actions the\ndevice supports and how these actions should be fulfilled.\n\nThe service then responds with text that is spoken back to the user (*Sure.*)\nalong with the device-specific command. The device knows how to handle this\ncommand: it turns on its LED!\n\nGet started\n-----------\n\nBring your ideas to life by embedding the Google Assistant\ninto your project and then adding unique functionality with Device\nActions. You can develop your project [using the Google Assistant service](/assistant/sdk/guides/service/python)."]]