歡迎使用 Google Home 開發人員中心,探索全新功能,瞭解如何開發智慧住宅動作。注意:請繼續在「動作」控制台中建立動作。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Smart Home ColorSpectrum Trait 結構定義
action.devices.traits.ColorSpectrum
- 此特徵屬於任何能夠設定色譜的裝置。這適用於採用 RGB 顏色範圍的「完整」彩色燈泡。光的 ColorSpectrum 和 ColorTemperature 可以任意組合。強調光源和 LED 燈條可能只有 Spectrum,而部分閱讀燈泡只有溫度。基本燈泡或智慧型插座上的啞鈴皆無
裝置屬性
屬性 |
定義 |
colorModel |
選填欄位,可設為 hsv 字串,表示 HSV (色調、飽和度、值) 色彩模型的裝置偏好設定。預設值為 rgb 。 |
同步處理要求和回應範例
{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"inputs": [{
"intent": "action.devices.SYNC"
}]
}
'use strict';
const {smarthome} = require('actions-on-google');
const functions = require('firebase-functions');
const app = smarthome();
app.onSync((body, headers) => {
return {
requestId: body.requestId,
payload: {
agentUserId: '1836.15267389',
devices: [{
id: '123',
type: 'action.devices.types.LIGHT',
traits: [
'action.devices.traits.ColorSpectrum'
],
name: {
defaultNames: ['AAA bulb A19 color hyperglow'],
name: 'lamp1',
nicknames: ['reading lamp']
},
willReportState: true,
attributes: {
colorModel: 'rgb'
},
deviceInfo: {
manufacturer: 'AAA',
model: 'hg11',
hwVersion: '1.2',
swVersion: '5.4'
},
customData: {
fooValue: 12,
barValue: false,
bazValue: 'dancing alpaca'
}
}]
}
};
});
// ...
exports.smarthome = functions.https.onRequest(app);
{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"payload": {
"agentUserId": "1836.15267389",
"devices": [
{
"id": "123",
"type": "action.devices.types.LIGHT",
"traits": [
"action.devices.traits.ColorSpectrum"
],
"name": {
"defaultNames": [
"AAA bulb A19 color hyperglow"
],
"name": "lamp1",
"nicknames": [
"reading lamp"
]
},
"willReportState": true,
"attributes": {
"colorModel": "rgb"
},
"deviceInfo": {
"manufacturer": "AAA",
"model": "hg11",
"hwVersion": "1.2",
"swVersion": "5.4"
},
"customData": {
"fooValue": 12,
"barValue": false,
"bazValue": "dancing alpaca"
}
}
]
}
}
裝置狀態:STATE
狀態 |
定義 |
color |
物件。目前色彩設定。由於指定的光源處於頻譜或溫度模式,因此這個物件包含相關模式中目前的色彩設定。
name 字串。如果色彩點 (頻譜或溫度) 與合作夥伴色彩清單中的預設名稱相符,請傳回名稱。
spectrumRGB 整數。使用 RGB 的頻譜值 (為整數的十六進位值)。
|
裝置指令
指令 |
參數/定義 |
action.devices.commands.ColorAbsolute |
color 物件。必要項目。包括 RGB 或溫度,以及名稱。
name 字串。使用者指令中提供的顏色名稱 (英文)。不一定適用 (相對指令)。
spectrumRGB 整數。使用 RGB 的頻譜值 (為整數的十六進位值)。
|
EXECUTE 要求和回應範例
將燈光設為紅色。
{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"inputs": [{
"intent": "action.devices.EXECUTE",
"payload": {
"commands": [{
"devices": [{
"id": "123",
"customData": {
"fooValue": 74,
"barValue": true,
"bazValue": "sheepdip"
}
}],
"execution": [{
"command": "action.devices.commands.ColorAbsolute",
"params": {
"color": {
"name": "red",
"spectrumRGB": 16711680
}
}
}]
}]
}
}]
}
'use strict';
const {smarthome} = require('actions-on-google');
const functions = require('firebase-functions');
const app = smarthome();
app.onExecute((body, headers) => {
return {
requestId: body.requestId,
payload: {
commands: [{
ids: ['123'],
status: 'SUCCESS',
states: {
color: {
name: 'red',
spectrumRGB: 12655639
}
}
}]
}
};
});
// ...
exports.smarthome = functions.https.onRequest(app);
{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"payload": {
"commands": [
{
"ids": [
"123"
],
"status": "SUCCESS",
"states": {
"color": {
"name": "red",
"spectrumRGB": 12655639
}
}
}
]
}
}
其他叫用範例如下:
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2023-03-31 (世界標準時間)。
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"缺少我需要的資訊"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"過於複雜/步驟過多"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"過時"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻譯問題"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"示例/程式碼問題"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"容易理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"確實解決了我的問題"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]