Alexa.PercentageController Interface

Implement the Alexa.PercentageController interface in your Alexa skill so that users can control properties of devices that can be expressed as a percentage. For more information about Smart Home skills, see Understand the Smart Home Skill API.

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 languages that the PercentageController interface supports, see List of Alexa Interfaces and Supported Languages.

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ätename> auf Anzahl Prozent.
Alexa, erhelle <Gerätename> um 10 Prozent.
Alexa, reduziere <Gerätename> um 20 Prozent.

アレクサ、<device name>を30パーセントに設定して。
アレクサ、<device name>を10パーセント上げて。
アレクサ、<device name>を20パーセント下げて。

After the customer says an utterance, 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.

Discover response example

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

Copied to clipboard.

{
  "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": ["OTHER"],
          "cookie": {},
          "capabilities": [
            {
              "type": "AlexaInterface",
              "interface": "Alexa.PercentageController",
              "version": "3",
              "properties": {
                "supported": [
                  {
                    "name": "percentage"
                  }
                ],
                "proactivelyReported": true,
                "retrievable": true
              }
            },
            {
              "type": "AlexaInterface",
              "interface": "Alexa",
              "version": "3"
            }
          ]
        }
      ]
    }
  }
}

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ätename> auf Anzahl Prozent.

アレクサ、<device name>を30パーセントに設定して。

SetPercentage directive payload details

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

SetPercentage directive example

The following example illustrates a SetPercentage directive that Alexa sends to your skill.

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

Copied to clipboard.

{
  "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, erhelle <Gerätename> um 10 Prozent.
Alexa, reduziere <Gerätename> um 20 Prozent.

アレクサ、<device name>を10パーセント上げて。
アレクサ、<device name>を20パーセント下げて。

AdjustPercentage directive payload details

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

AdjustPercentage directive example

The following example illustrates an AdjustPercentage directive that Alexa sends to your skill.

{
  "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 an 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

Copied to clipboard.

{
  "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 an 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 details about state reports, see Understand State and Change Reporting.

StateReport response event example

Copied to clipboard.

{
  "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 details about change reports, see Understand State and Change Reporting.

ChangeReport event example

Copied to clipboard.

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