Alexa.PowerLevelController Interface
Implement the Alexa.PowerLevelController
interface in your Alexa skill so that users can control the power level of their smart home devices. For more information about Smart Home skills, see Understand Smart Home Skills.
Use this interface for devices that support power-level control, such as a dimmer switch. For more general properties that can be expressed as a percentage, implement the Alexa.PercentageController interface instead.
For the list of languages that the PowerLevelController
interface supports, see List of Alexa Interfaces and Supported Languages.
Utterances
When you use the Alexa.PowerLevelController
interface, the voice interaction model is already built for you. The following examples show some customer utterances:
Alexa, set the power to 40 percent on the fan.
Alexa, increase the power level by 12 on the light switch.
アレクサ、ファンの風量を40パーセントにして。
アレクサ、電気のスイッチでレベルを12にあげて。
After the customer says an utterance, Alexa sends a corresponding directive to your skill.
Properties
The powerLevel property
The Alexa.PowerLevelController
interface uses the powerLevel
property as the primary property. The property represents the power level of a device expressed as an integer percentage between 0 and 100 inclusive. If the powerLevel
property is used to represent a change, then valid values are from -100 to 100 inclusive.
Discovery
You describe endpoints that support Alexa.PowerLevelController
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 a light that supports the Alexa.PowerLevelController
and Alexa.ColorController
interfaces.
{
"event": {
"header": {
"namespace": "Alexa.Discovery",
"name": "Discover.Response",
"payloadVersion": "3",
"messageId": "a unique identifier, preferably a version 4 UUID"
},
"payload": {
"endpoints": [
{
"endpointId": "unique ID of the endpoint",
"manufacturerName": "<the manufacturer name of the endpoint>",
"description": "<a description that is shown in the Alexa app>",
"friendlyName": "Living Room Light",
"displayCategories": ["LIGHT"],
"additionalAttributes": {
"manufacturer": "the manufacturer name of the endpoint",
"model" : "the model of the device",
"serialNumber": "the serial number of the device",
"firmwareVersion" : "the firmware version of the device",
"softwareVersion": "the software version of the device",
"customIdentifier": "your custom identifier for the device"
},
"cookie": {},
"capabilities": [
{
"type": "AlexaInterface",
"interface": "Alexa.PowerLevelController",
"version": "3",
"properties": {
"supported": [
{
"name": "powerLevel"
}
],
"proactivelyReported": true,
"retrievable": true
}
},
{
"type": "AlexaInterface",
"interface": "Alexa.ColorController",
"version": "3",
"properties": {
"supported": [
{
"name": "color"
}
],
"proactivelyReported": true,
"retrievable": true
}
},
{
"type": "AlexaInterface",
"interface": "Alexa.EndpointHealth",
"version": "3",
"properties": {
"supported": [
{
"name": "connectivity"
}
],
"proactivelyReported": true,
"retrievable": true
}
},
{
"type": "AlexaInterface",
"interface": "Alexa",
"version": "3"
}
]
}
]
}
}
}
Directives
SetPowerLevel directive
Support the SetPowerLevel
directive so that customers can set the power level on devices.
The following example shows a customer utterance:
Alexa, set the power to 40 percent on the fan.
アレクサ、ファンの風量を40パーセントにして。
SetPowerLevel directive payload details
Field | Description | Type |
---|---|---|
powerLevel |
The power level to set the device to. | Integer |
SetPowerLevel directive example
The following example illustrates a SetPowerLevel
directive that Alexa sends to your skill.
{
"directive": {
"header": {
"namespace": "Alexa.PowerLevelController",
"name": "SetPowerLevel",
"messageId": "message id",
"correlationToken": "<an opaque correlation token>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<an OAuth2 bearer token>"
},
"endpointId": "endpoint ID",
"cookie": {}
},
"payload": {
"powerLevel": 40
}
}
}
SetPowerLevel response event
If you handle a SetPowerLevel
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.
SetPowerLevel response event example
{
"event": {
"header": {
"namespace": "Alexa",
"name": "Response",
"messageId": "a unique identifier, preferably a version 4 UUID",
"correlationToken": "<an opaque correlation token>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<an OAuth2 bearer token>"
},
"endpointId": "endpoint ID"
},
"payload": {}
},
"context": {
"properties": [
{
"namespace": "Alexa.PowerLevelController",
"name": "powerLevel",
"value": 40,
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
}
]
}
}
SetPowerLevel directive error handling
If you can't handle a SetPowerLevel
directive successfully, respond with an Alexa.ErrorResponse event.
AdjustPowerLevel directive
Support the AdjustPowerLevel
directive so that customers can adjust the power level on devices.
The following example shows a customer utterance:
Alexa, increase the power level by 12 on the light switch.
アレクサ、電気のスイッチでレベルを12にあげて。
AdjustPowerLevel directive payload details
Field | Description | Type |
---|---|---|
powerLevelDelta |
The amount by which to change the power level. | Integer |
AdjustPowerLevel directive example
The following example illustrates an AdjustPowerLevel
directive that Alexa sends to your skill.
{
"directive": {
"header": {
"namespace": "Alexa.PowerLevelController",
"name": "AdjustPowerLevel",
"messageId": "message id",
"correlationToken": "<an opaque correlation token>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<an OAuth2 bearer token>"
},
"endpointId": "endpoint ID",
"cookie": {}
},
"payload": {
"powerLevelDelta": 12
}
}
}
AdjustPowerLevel response event
If you handle an AdjustPowerLevel
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.
AdjustPowerLevel response event example
{
"event": {
"header": {
"namespace": "Alexa",
"name": "Response",
"messageId": "a unique identifier, preferably a version 4 UUID",
"correlationToken": "<an opaque correlation token>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<an OAuth2 bearer token>"
},
"endpointId": "endpoint ID"
},
"payload": {}
},
"context": {
"properties": [
{
"namespace": "Alexa.PowerLevelController",
"name": "powerLevel",
"value": 52,
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
}
]
}
}
AdjustPowerLevel directive error handling
If you can't handle an AdjustPowerLevel
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 details about state reports, see Understand State and Change Reporting.
StateReport response event example
{
"event": {
"header": {
"namespace": "Alexa",
"name": "StateReport",
"messageId": "a unique identifier, preferably a version 4 UUID",
"correlationToken": "<an opaque correlation token>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<an OAuth2 bearer token>"
},
"endpointId": "endpoint ID"
},
"payload": {}
},
"context": {
"properties": [
{
"namespace": "Alexa.PowerLevelController",
"name": "powerLevel",
"value": 52,
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 0
}
]
}
}
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 details about change reports, see Understand State and Change Reporting.
ChangeReport event example
{
"event": {
"header": {
"namespace": "Alexa",
"name": "ChangeReport",
"messageId": "a unique identifier, preferably a version 4 UUID",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<an OAuth2 bearer token>"
},
"endpointId": "endpoint ID"
},
"payload": {
"change": {
"cause": {
"type": "PHYSICAL_INTERACTION"
},
"properties": [
{
"namespace": "Alexa.PowerLevelController",
"name": "powerLevel",
"value": 75,
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 0
}
]
}
}
},
"context": {
"namespace": "Alexa.EndpointHealth",
"name": "connectivity",
"value": {
"value": "OK"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 0
}
}