Grato por sua visita. Neste momento esta página está apenas disponível em inglês.

Alexa.ColorController Interface

The Alexa.ColorController interface describes the messages used to change the color of an endpoint such as a color-changing light bulb.

For the list of locales that are supported for the ColorController interface, see List of Capability Interfaces and Supported Locales.

Utterances

When you use the Alexa.ColorController interface, the voice interaction model is already built for you. The following examples show some customer utterances:

Alexa, set the front porch light to blue.
Alexa, set the bedroom light to red.
Alexa, change the kitchen to the color blue.

Alexa, setze Wohnzimmerlicht auf rosa.

After the customer says one of these utterances, Alexa sends a corresponding directive to your skill.

Properties and Objects

The color object

The color object represents the color of an endpoint. Colors are specified by using the hue, saturation, brightness (HSB) color model. For more information, see colorizer.org and The HSB Color System.

Discovery

You describe endpoints that support Alexa.ColorController using the standard discovery mechanism described in Alexa.Discovery.

Set retrievable to true for all of the interfaces and properties that you report when Alexa sends your skill a state report request. Set proactivelyReported to true for interfaces and properties that you proactively report to Alexa in a change report.

For the full list of display categories, see display categories.

Discover response example

The following example shows a Discover.Response message for an endpoint that supports the Alexa.PowerController and Alexa.ColorController interfaces.

{
  "event": {
    "header": {
      "namespace": "Alexa.Discovery",
      "name": "Discover.Response",
      "payloadVersion": "3",
      "messageId": "<message id>"
    },
    "payload": {
      "endpoints":[
        {
          "endpointId": "<unique ID of the endpoint>",
          "manufacturerName": "<the manufacturer name of the endpoint>",
          "modelName": "<the model name of the endpoint>",
          "description": "<a description that is shown in the Alexa app>",
          "friendlyName": "<device name, displayed in the Alexa app>",
          "displayCategories": ["LIGHT"],
          "cookie": {},
          "capabilities": [
            {
              "type": "AlexaInterface",
              "interface": "Alexa.PowerController",
              "version": "3",
              "properties": {
                "supported": [
                  {
                    "name": "powerState"
                  }
                ],
                "proactivelyReported": true,
                "retrievable": true
              }
            },
            {
              "type": "AlexaInterface",
              "interface": "Alexa.ColorController",
              "version": "3",
              "properties": {
                "supported": [
                  {
                    "name": "color"
                  }
                ],
                "proactivelyReported": true,
                "retrievable": true
              }
            }
          ]
        }
      ]
    }
  }
}

Directives

SetColor directive

Support the SetColor directive so that customers can change the color of devices.

The following example shows a customer utterance:

Alexa, set the bedroom light to red.

Alexa, setze Wohnzimmerlicht auf rosa.

SetPercentage directive payload details

Field Description Type
color The color to set the device to. Object

SetColor directive example

{
  "directive": {
    "header": {
      "namespace": "Alexa.ColorController",
      "name": "SetColor",
      "messageId": "<message id>",
      "correlationToken": "<an opaque correlation token>",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "<an OAuth2 bearer token>"
      },
      "endpointId": "<endpoint id>",
      "cookie": {}
    },
    "payload": {
      "color": {
        "hue": 350.5,
        "saturation": 0.7138,
        "brightness": 0.6524
      }
    }
  }
}

SetColor response event

If you handle a SetColor directive successfully, respond with an Alexa.Response event. In the context object, include the values of all properties that changed. You can respond synchronously or asynchronously. If you respond asynchronously, include a correlation token and a scope with an authorization token.

SetColor response event example

{
  "event": {
    "header": {
      "namespace": "Alexa",
      "name": "Response",
      "messageId": "<message id>",
      "correlationToken": "<an opaque correlation token>",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "<an OAuth2 bearer token>"
      },
      "endpointId": "<endpoint id>"
    },
    "payload": {}
  },
  "context": {
    "properties": [
      {
        "namespace": "Alexa.ColorController",
        "name": "color",
        "value": {
            "hue": 350.5,
            "saturation": 0.7138,
            "brightness": 0.6524
        },
        "timeOfSample": "2019-07-03T16:20:50Z",
        "uncertaintyInMilliseconds": 500
      }
    ]
  }
}

SetColor directive error handling

If you can't handle a SetColor directive successfully, respond with an Alexa.ErrorResponse event.

State reporting

Alexa sends a ReportState directive to request information about the state of an endpoint. When Alexa sends a ReportState directive, you send a StateReport event in response. The response contains the current state of all of the retrievable properties in the context object. You identify your retrievable properties in your discovery response. For more information about state reports, see Understand State Reporting.

StateReport response event example

{
  "event": {
    "header": {
      "namespace": "Alexa",
      "name": "StateReport",
      "messageId": "<message id>",
      "correlationToken": "<an opaque correlation token>",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "<an OAuth2 bearer token>"
      },
      "endpointId": "<endpoint id>"
    },
    "payload": {}
  },
  "context": {
    "properties": [
      {
        "namespace": "Alexa.ColorController",
        "name": "color",
        "value": {
            "hue": 350.5,
            "saturation": 0.7138,
            "brightness": 0.6524
        },
        "timeOfSample": "2019-07-03T16:20:50Z",
        "uncertaintyInMilliseconds": 500
      }
    ]
  }
}

Change reporting

You send a ChangeReport event to proactively report changes in the state of an endpoint. You identify the properties that you proactively report in your discovery response. For more information about change reports, see Understand State Reporting.

For lighting endpoints that support both the ColorController and ColorTemperatureController interfaces, report the state of color when an endpoint is set to a color, and report the state of colorTemperatureInKelvin when an endpoint is set to a shade of white.

ChangeReport event example

{
  "event": {
    "header": {
      "namespace": "Alexa",
      "name": "ChangeReport",
      "messageId": "<message id>",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "<an OAuth2 bearer token>"
      },
      "endpointId": "<endpoint id>"
    },
    "payload": {
      "change": {
        "cause": {
          "type": "PHYSICAL_INTERACTION"
        },
        "properties": [
          {
            "namespace": "Alexa.ColorController",
            "name": "color",
            "value": {
                "hue": 280,
                "saturation": 0.9,
                "brightness": 0.9
            },
            "timeOfSample": "2019-07-03T16:20:50Z",
            "uncertaintyInMilliseconds": 500
          }
        ]
      }
    }
  },
  "context": {}
}