Đăng ký đặc điểm
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trợ lý Google phải liên kết được một truy vấn với một lệnh để gửi đến thiết bị của bạn. Để làm được điều này, bạn cần khai báo những loại khả năng mà thiết bị của bạn hỗ trợ. Những khả năng này được gọi là đặc điểm. Bạn khai báo các trait này trong mẫu thiết bị của mình.
Google đã tạo ra nhiều đặc điểm phổ biến trên nhiều thiết bị. Các trait này không chỉ gắn liền với một loại thiết bị nào nên bạn có thể sử dụng tuỳ ý.
Thêm trait
Trước đây, bạn đã xác định một mô hình, giờ hãy cập nhật mô hình đó bằng cách thêm một trait. Trong trường hợp này, hãy thêm trait Bật/Tắt để điều khiển đèn LED gắn trên thiết bị.
Mở dự án trong Bảng điều khiển Actions.
Chọn thẻ Device registration (Đăng ký thiết bị) trên thanh điều hướng bên trái.
Nhấp vào một mô hình trong danh sách để chỉnh sửa.
Nhấp vào biểu tượng bút chì trong hộp Đặc điểm được hỗ trợ để thêm đặc điểm đó.
Chọn hộp đánh dấu OnOff. Nhấp vào LƯU.
Hãy nhớ lưu các thay đổi đối với mô hình. Nhấp lại vào LƯU.
Bước tiếp theo
Xử lý lệnh
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\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)"]]