สคีมาลักษณะของ Smart Home ColorTemperature

action.devices.traits.ColorTemperature - ลักษณะนี้เป็นของอุปกรณ์ทุกเครื่องที่ตั้งค่าอุณหภูมิสีได้

ตัวเลือกนี้มีผลกับหลอดไฟ "อบอุ่น" ที่มีจุดสีเป็นหน่วยเคลวิน ซึ่งโดยทั่วไปจะเป็นวิธีการที่แยกต่างหากจาก ColorSpectrum และอาจมีจุดสีขาวที่มีอยู่ผ่านทางอุณหภูมิซึ่งสเปกตรัมเข้าถึงไม่ได้ Google อาจเลือกโหมดที่เหมาะสมเพื่อใช้ตามคำขอและประเภทแสง ทั้งนี้ขึ้นอยู่กับคุณลักษณะที่มีอยู่ (เช่น ทำให้ไฟห้องนั่งเล่นเป็นสีขาวอาจส่งคำสั่งอุณหภูมิไปยังหลอดไฟบางดวง และคำสั่งสเปกตรัมไปยังแถบ LED)

ATTRIBUTES ของอุปกรณ์

แอตทริบิวต์ คำจำกัดความ
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"
       
}
     
}
   
]
 
}
}

สถานะอุปกรณ์

รัฐ คำจำกัดความ
color ออบเจ็กต์ การตั้งค่าสีปัจจุบัน เนื่องจากแสงหนึ่งๆ อยู่ในโหมดสเปกตรัมหรืออุณหภูมิ วัตถุนี้จึงมีการตั้งค่าสีปัจจุบันในโหมดที่เกี่ยวข้อง
  • สตริง name หากจุดสี (สเปกตรัมหรืออุณหภูมิ) ตรงกับชื่อที่กำหนดล่วงหน้าในรายการสีของพาร์ทเนอร์ ให้แสดงชื่อ
  • temperature จำนวนเต็ม อุณหภูมิสีในหน่วยเคลวิน

ตัวอย่างคำขอและการตอบกลับ QUERY

ตอนนี้อุณหภูมิสีของไฟฉันอยู่ที่เท่าไหร่
คำขอNode.jsJSON
{
 
"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"
     
}
   
}
 
}
}

COMMANDS ของอุปกรณ์

คำสั่ง พารามิเตอร์/คำจำกัดความ
action.devices.commands.ColorAbsolute ออบเจ็กต์ color รายการ ต้องระบุ โดยจะรวมถึง RGB หรือ Temperature และชื่อ (ไม่บังคับ)
  • สตริง name ชื่อสี (เป็นภาษาอังกฤษ) ตามที่ระบุไว้ในคำสั่งของผู้ใช้ ใช้ไม่ได้เสมอไป (สำหรับคำสั่งที่เกี่ยวข้อง)
  • temperature จำนวนเต็ม อุณหภูมิสีในหน่วยเคลวิน

ตัวอย่างคำขอและการตอบกลับ

ปรับแสงเป็นสีขาวนวล
คำขอNode.jsJSON
{
 
"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
         
}
       
}
     
}
   
]
 
}
}