注册特征
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Google 助理需要能够将询问与要发送到设备的命令相关联。为此,您需要声明设备支持的功能类型。这些能力称为特征。您需要在设备模型中声明这些特征。
Google 已经创建了可在众多设备上找到的各种通用特征。这些特征并非仅与一种设备类型相关联,您可以根据需要使用它们。
添加特征
您之前定义了模型,现在通过添加特征来更新模型。在本例中,请添加“开启/关闭”特征来控制附加到设备的 LED。
在 Actions 控制台中打开该项目。
从左侧导航栏中选择设备注册标签页。
点击列表中的某个模型即可对其进行修改。
点击支持的特征框中的铅笔图标即可添加该特征。
选中 OnOff 复选框。点击保存。
请务必保存对模型所做的更改。再次点击保存。
后续步骤
处理命令
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eGoogle Assistant utilizes "traits" to link user queries to device commands, requiring developers to define device capabilities within their device model.\u003c/p\u003e\n"],["\u003cp\u003eGoogle provides pre-built traits for common device functionalities, offering flexibility in implementation across various device types.\u003c/p\u003e\n"],["\u003cp\u003eTo add a trait, developers can access their device model through the Actions Console, select the desired trait from the available options, and save the changes.\u003c/p\u003e\n"],["\u003cp\u003eThe example demonstrates adding an On/Off trait for controlling an LED, illustrating the process of extending device functionality.\u003c/p\u003e\n"]]],["Device functionality is enabled by declaring supported abilities, known as traits, within a device model. These traits, provided by Google, are reusable across various devices. To add a trait, users must access the Actions Console, navigate to Device Registration, select a model, and edit its Supported traits. For instance, to add On/Off control for an LED, the OnOff trait is selected and saved in the device's model, with another save step to finalize.\n"],null,["# Register Traits\n\nThe Google Assistant needs to be able to associate a query with a\ncommand to send to your device. For this to work, you need to declare what kinds\nof abilities your device supports. These abilities are known as *traits*. You\ndeclare these traits within your device model.\n\nGoogle has already created a wide variety of common [traits](/assistant/sdk/reference/traits)\nfound on many devices. These traits are not tied to just one device type, you can\nuse them as you choose.\n\nAdd a trait\n-----------\n\nYou previously defined a model, now update it by adding a trait. In this case,\nadd an On/Off trait to control an LED attached to your device.\n\n1. Open the project in the [Actions Console](https://console.actions.google.com/).\n\n2. Select the **Device registration** tab from the left navbar.\n\n3. Click a model from the list to edit it.\n\n4. Click the pencil in the **Supported traits** box to add the trait.\n\n5. Select the **OnOff** checkbox. Click **SAVE**.\n\n6. Make sure to save changes to the model. Click **SAVE** again.\n\nNext step\n---------\n\n[Handle Commands](/assistant/sdk/guides/service/python/extend/handle-device-commands)"]]