スマートホーム 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"
       
}
     
}
   
]
 
}
}

デバイスのステータス

状態 定義
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
         
}
       
}
     
}
   
]
 
}
}
他の呼び出しの例を以下に示します。
  • 「ライトを緑にして」
  • 「電気スタンドを赤に変えて」