Alexa.PercentageController Interface

The Alexa.PercentageController interface describes the messages used to control properties of endpoints that can be expressed as a percentage.

Use this interface only if there is not a more specific controller interface that applies to your device. For example, if you want to handle requests specific to brightness values, implement the Alexa.BrightnessController interface instead. If you want to handle requests specific to the power level of an endpoint such as a dimmer switch, implement the Alexa.PowerLevelController interface instead.

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

Utterances

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

Alexa, set the <device name> to thirty percent.
Alexa, increase <device name> by ten percent.
Alexa, decrease <device name> by twenty percent.

Alexa, stelle <Geräteame> auf Anzahl Prozent.
Alexa, erhöhe <Gerätename> um 10 Prozent.
Alexa, reduziere <Gerätename> um 20 Prozent.

deviceのグループを30%に設定して
deviceを15%明るくしてください

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

Properties

The percentage property

The Alexa.PercentageController interface uses the percentage property as the primary property. The property is an integer and valid values from 0 to 100 inclusive. If the percentage property is used to represent a change, then valid values are from -100 to 100 inclusive.

Discovery

You describe endpoints that support Alexa.PercentageController 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.

Discovery example

The following example shows a Discover.Response message for an endpoint that supports the Alexa.PercentageController interface.

{
    "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>",
                    "friendlyName": "<device name, displayed in the Alexa app>",
                    "description": "<a description that is shown in the Alexa app>",
                    "displayCategories": ["OTHER"],
                    "cookie": {},
                    "capabilities": [
                        {
                            "type": "AlexaInterface",
                            "interface": "Alexa.PercentageController",
                            "version": "3",
                            "properties": {
                                "supported": [
                                    {
                                        "name": "percentage"
                                    }
                                ],
                                "proactivelyReported": true,
                                "retrievable": true
                            }
                        }
                    ]
                }
            ]
        }
    }
}

Directives

SetPercentage directive

Support the SetPercentage directive so that customers can set the percentage value of a device setting.

The following example shows a customer utterance:

Alexa, set the <device name> to thirty percent.

Alexa, stelle <Geräteame> auf Anzahl Prozent.

deviceのグループを30%に設定して

SetPercentage directive payload details

Field Description Type
percentage The percentage to set the device to. Integer

SetPercentage directive example

{
  "directive": {
    "header": {
      "namespace": "Alexa.PercentageController",
      "name": "SetPercentage",
      "messageId": "<message id>",
      "correlationToken": "<an opaque correlation token>",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "<an OAuth2 bearer token>"
      },
      "endpointId": "<endpoint id>",
      "cookie": {}
    },
    "payload": {
      "percentage": 74
    }
  }
}

SetPercentage response event

If you handle a SetPercentage 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.

SetPercentage 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.PercentageController",
                "name": "percentage",
                "value": 74,
                "timeOfSample": "2017-02-03T16:20:50.52Z",
                "uncertaintyInMilliseconds": 500
            }
        ]
    }
}

SetPercentage directive error handling

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

AdjustPercentage directive

Support the AdjustPercentage directive so that customers can adjust the percentage value of a device setting.

The following example shows a customer utterance:

Alexa, increase <device name> by ten percent.
Alexa, decrease <device name> by twenty percent.

Alexa, erhöhe <Gerätename> um 10 Prozent.
Alexa, reduziere <Gerätename> um 20 Prozent.

deviceを15%明るくしてください

AdjustPercentage directive payload details

Field Description Type
percentageDelta The amount by which to change the percentage. Integer

AdjustPercentage directive example

{
  "directive": {
    "header": {
      "namespace": "Alexa.PercentageController",
      "name": "AdjustPercentage",
      "messageId": "<message id>",
      "correlationToken": "<an opaque correlation token>",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
          "type": "BearerToken",
          "token": "<an OAuth2 bearer token>"
        },
        "endpointId": "<endpoint id>",
        "cookie": {}
      },
    "payload": {
      "percentageDelta": -20
    }
  }
}

AdjustPercentage response event

If you handle a AdjustPercentage 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.

AdjustPercentage 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.PercentageController",
                "name": "percentage",
                "value": 54,
                "timeOfSample": "2017-02-03T16:20:50.52Z",
                "uncertaintyInMilliseconds": 500
            }
        ]
    }
}

AdjustPercentage directive error handling

If you can't handle a AdjustPercentage 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.PercentageController",
           "name": "percentage",
           "value": 30,
           "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 more information about change reports, see Understand State Reporting.

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.PercentageController",
                "name": "percentage",
                "value": 65,
                "timeOfSample": "2017-02-03T16:20:50.52Z",
                "uncertaintyInMilliseconds": 0
            }
        ]
      }
    }
  },
  "context": {}
}