歡迎使用 Google Home 開發人員中心,探索全新功能,瞭解如何開發智慧住宅動作。注意:請繼續在「動作」控制台中建立動作。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
智慧型住宅 ColorTemperature Trait 結構定義
action.devices.traits.ColorTemperature
- 此屬性屬於任何能設定色溫的裝置。
這適用於在凱文的色彩點「暖」的燈泡。這通常與
ColorSpectrum 分開,而且 Spectrum 可能無法透過 Temperature 取得白色點。Google 可能會根據可用的特性,根據要求和光源類型挑選合適的模式 (例如,
將客廳的燈光調整為白色,可能會將溫度指令傳送至部分燈泡,並將頻譜指令傳送至 LED 燈條)。
裝置屬性
屬性 |
定義 |
temperatureMinK |
選填欄位,如果已設定 temperatureMaxK ,則為必要欄位。光源所支援的最低色溫 (以克耳文表示)。 |
temperatureMaxK |
選填欄位,如果已設定 temperatureMinK ,則為必要欄位。光源支援的最高色溫,單位為克耳文。 |
同步處理要求和回應範例
{
"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.ColorTemperature'
],
name: {
defaultNames: ['AAA bulb A19 color hyperglow'],
name: 'lamp1',
nicknames: ['reading lamp']
},
willReportState: true,
attributes: {
temperatureMinK: 2000,
temperatureMaxK: 6500
},
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.ColorTemperature"
],
"name": {
"defaultNames": [
"AAA bulb A19 color hyperglow"
],
"name": "lamp1",
"nicknames": [
"reading lamp"
]
},
"willReportState": true,
"attributes": {
"temperatureMinK": 2000,
"temperatureMaxK": 6500
},
"deviceInfo": {
"manufacturer": "AAA",
"model": "hg11",
"hwVersion": "1.2",
"swVersion": "5.4"
},
"customData": {
"fooValue": 12,
"barValue": false,
"bazValue": "dancing alpaca"
}
}
]
}
}
裝置狀態:STATE
狀態 |
定義 |
color |
物件。目前色彩設定。由於指定的光源處於頻譜或溫度模式,因此這個物件包含相關模式中目前的色彩設定。
name 字串。如果色彩點 (頻譜或溫度) 與合作夥伴色彩清單中的預設名稱相符,請傳回名稱。
temperature 整數。克氏的色溫。
|
QUERY 要求與回應範例
我目前設定的淺色溫度是多少?
{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"inputs": [{
"intent": 'action.devices.QUERY',
"payload": {
"devices": [{
"id": "123",
"customData": {
"fooValue": 74,
"barValue": true,
"bazValue": "foo"
}
}]
}
}]
}
'use strict';
const {smarthome} = require('actions-on-google');
const functions = require('firebase-functions');
const app = smarthome();
app.onQuery((body, headers) => {
return {
requestId: body.requestId,
payload: {
devices: {
123: {
online: true,
color: {
name: 'warm white',
temperature: 25000
},
status: 'SUCCESS'
}
}
}
};
});
// ...
exports.smarthome = functions.https.onRequest(app);
{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"payload": {
"devices": {
"123": {
"online": true,
"color": {
"name": "warm white",
"temperature": 25000
},
"status": "SUCCESS"
}
}
}
}
裝置指令
指令 |
參數/定義 |
action.devices.commands.ColorAbsolute |
color 物件。必要項目。包括 RGB 或溫度,以及名稱。
name 字串。使用者指令中提供的顏色名稱 (英文)。不一定適用 (相對指令)。
temperature 整數。克氏的色溫。
|
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": "soft white",
"temperature": 2700
}
}
}]
}]
}
}]
}
'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: 'soft white',
temperature: 2700
}
}
}]
}
};
});
// ...
exports.smarthome = functions.https.onRequest(app);
{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"payload": {
"commands": [
{
"ids": [
"123"
],
"status": "SUCCESS",
"states": {
"color": {
"name": "soft white",
"temperature": 2700
}
}
}
]
}
}
除非另有註明,否則本頁面中的內容是採用創用 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":"其他"
}]