Schema für Farbspektrumsmerkmale von Smart-Home-Geräten

action.devices.traits.ColorSpectrum: Diese Eigenschaft gehört zu jedem Gerät, das ein Farbspektrum festlegen kann. Dies gilt für „Vollfarbenlampen“, die RGB-Farbbereiche verwenden. Die Leuchten können eine beliebige Kombination aus ColorSpectrum und ColorTemperature haben. Akzentleuchten und LED-Streifen haben möglicherweise nur ein Spektrum, während einige Leselampen nur Temperatur haben. Einfache Glühbirnen oder gedämpfte Leuchten an intelligenten Steckdosen haben keine der beiden Funktionen.

Geräte-ATTRIBUTE

Attribut Definition
colorModel Optional. Kann auf den String hsv gesetzt werden, um die Gerätepräferenz für das HSV-Farbmodell (Farbton, Sättigung, Wert) anzugeben. Der Standardwert ist rgb.

Beispiel für SYNC-Anfrage und -Antwort

{
   
"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"
       
}
     
}
   
]
 
}
}

Gerät STATES

Status Definition
color Objekt. Aktuelle Farbeinstellung. Da sich ein bestimmtes Licht im Spektrum-ODER-Temperaturmodus befindet, enthält dieses Objekt die aktuellen Farbeinstellungen im relevanten Modus.
  • String name. Wenn der Farbpunkt (Spektrum oder Temperatur) mit einem voreingestellten Namen in der Farbliste des Partners übereinstimmt, wird der Name zurückgegeben.
  • spectrumRGB Ganzzahl. Spektrumwert in RGB (hexadezimaler Wert als Ganzzahl).

BEFEHLE auf dem Gerät

Befehl Parameter/Definition
action.devices.commands.ColorAbsolute color-Objekt. Erforderlich. Enthält RGB oder Temperatur und optional einen Namen.
  • String name. Farbname (auf Englisch), wie im Befehl des Nutzers angegeben. Nicht immer verfügbar (für relative Befehle).
  • spectrumRGB Ganzzahl. Spektrumwert in RGB (hexadezimaler Wert als Ganzzahl).

Beispiel für Anfrage und Antwort AUSFÜHREN

Stell das Licht auf Rot.
{
 
"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
         
}
       
}
     
}
   
]
 
}
}
Weitere Beispielaufrufe:
  • Stell die Lampen auf Grün.
  • Ändere meine Schreibtischlampe zu Rot.