스마트 홈 ColorSpectrum Trait 스키마

action.devices.traits.ColorSpectrum - 이 특성은 색상 스펙트럼을 설정할 수 있는 모든 기기에 속합니다. 이는 RGB 색상 범위를 사용하는 '풀' 색상 전구에 적용됩니다. 광원은 ColorSpectrum과 ColorTemperature의 조합이 있을 수 있습니다. 강조 조명과 LED 스트립에는 스펙트럼만 있을 수 있는 반면, 일부 독서 전구에는 온도만 있습니다. 기본 전구나 스마트 플러그의 멍청한 조명에는 둘 다 없습니다.

기기 ATTRIBUTES

속성 정의
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
         
}
       
}
     
}
   
]
 
}
}
다른 호출 예시는 다음과 같습니다.
  • 조명을 녹색으로 설정해 줘
  • 책상 램프를 빨간색으로 바꿔 줘.