歡迎來到 Google Home 開發人員中心,你可以在這裡學習如何學習智慧型住宅動作。注意事項:您將在 Actions 主控台建構動作。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
智慧型住宅色溫特徵結構定義
action.devices.traits.ColorTemperature
- 這個特性屬於任何可設定色溫的裝置。
這適用於在克爾文取色點的「暖色」燈泡。這通常是與
ColorSpectrum 的獨立形態,而且可能有 Spectrum 無法觸及的白點可用的白點。Google 可能會根據可用特徵,根據要求和光源選擇適當的模式。舉例來說,「將客廳的燈切換為白色」
可能會向部分燈泡傳送「溫度」指令,並將 Spectrum 指令傳送至 LED 燈條。
裝置屬性
屬性 |
定義 |
temperatureMinK |
(選填) 如果已設定 temperatureMaxK ,則為必要欄位。指示燈支援的最低色溫,以克耳文表示。 |
temperatureMaxK |
(選填) 如果已設定 temperatureMinK ,則為必要欄位。指示燈支援的最高色溫,以克耳文為單位。 |
SYNC 要求與回應範例
{
"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"
}
}
]
}
}
裝置狀態
狀態 |
定義 |
color |
物件。目前的色彩設定。由於指定燈具處於光譜或溫度模式,因此這個物件會在相關模式下包含目前的色彩設定。
name 字串。如果色點 (Spectrum 或 Temperature) 與合作夥伴顏色清單中的預設名稱相符,請傳回該名稱。
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 整數。色溫 (克耳文)。
|
執行要求與回應範例
將燈光調整為柔和的白色。
{
"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-09-21 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["Incorrect information","incorrectInformation","thumb-down"],["Not enough information/samples","notEnoughInformationSamples","thumb-down"],["Too complicated","tooComplicated","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2023-09-21 (世界標準時間)。"],[],[]]