Google Home デベロッパー センターにようこそ。スマートホーム アクションの開発方法を学ぶことができます。注: アクションの作成は、引き続き Actions Console で行います。
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
スマートホーム ColorSpectrum 特性のスキーマ
action.devices.traits.ColorSpectrum
- このトレイトは、カラー スペクトルを設定できるすべてのデバイスに属します。これは、RGB カラー範囲を使用するフルカラー電球に適用されます。ライトは、ColorSpectrum と ColorTemperature の任意の組み合わせを持つことができます。アクセント ライトと LED ストリップには Spectrum のみがあるのに対し、読書灯には温度のみがあります。シンプルな電球や、スマート コンセントにつながった単純なライトでは、どちらも使用しません。
デバイスの属性
属性 |
定義 |
colorModel |
(省略可)文字列 hsv に設定すると、HSV(色相、彩度、明度)カラーモデルのデバイス設定を指定できます。デフォルトは rgb です。 |
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.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 のスペクトル値(16 進値を整数で)。
|
デバイスのコマンド
コマンド |
パラメータ / 定義 |
action.devices.commands.ColorAbsolute |
color - オブジェクト。必須。RGB または温度と、必要に応じて名前が含まれます。
name 文字列。ユーザーのコマンドで指定されている色の名前(英語)。常に提供されるとは限りません(相対コマンドの場合)。
spectrumRGB - 整数。RGB のスペクトル値(16 進値を整数で)。
|
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
}
}
}
]
}
}
その他の呼び出しの例を次に示します。
- 「ライトを緑にして」
- 「電気スタンドを赤に変えて」
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-02-01 UTC.
[{
"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":"その他"
}]