Alexa.PercentageController Interface 3


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 details about Smart Home skills, see Understand Smart Home Skills.

Use this interface only if there isn't 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. For the definitions of the message properties, see Alexa Interface Message and Property Reference.

Utterances

When you use the Alexa.PercentageController interface, the voice interaction model is already built for you. After the user says one of the following utterances, Alexa sends a corresponding directive to your skill.

The following examples show user 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 dreißig Prozent.
Alexa, erhöhe <Gerätename> um zehn Prozent.
Alexa, reduziere <Gerätename> um zwanzig Prozent.

Alexa, règle le salon à trente pour cent.
Alexa, augmente le salon de dix pour cent.
Alexa, réduis le salon de vingt pour cent.

Alexa, {डिवाइस का नाम} को तीस प्रतिशत पर सेट करें।
Alexa, {डिवाइस का नाम} को दस प्रतिशत बढ़ा दें।
Alexa, {डिवाइस का नाम} को बीस प्रतिशत घटाएं।

Alexa, imposta il salotto al trenta percento.
Alexa, aumenta il salotto del dieci percento.
Alexa, diminuisci il salotto del venti percento.

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

Alexa, coloque a luz da cozinha em trinta por cento.
Alexa, ajusta a luz do quarto para trinta por cento.
Alexa, Alexa, aumente a luz da sala em dez por cento.
Alexa, Alexa, aumente o brilho da luz da sala em dez por cento.
Alexa, Alexa, diminua a luz da sala em dez por cento.
Alexa, diminua o brilho da luz da sala em dez por cento.

Alexa, configura el dispositivo al treinta por ciento.
Alexa, sube la luz en un diez por ciento.
Alexa, disminuye la luz en un veinte por ciento.

Reportable properties

The Alexa.PercentageController interface uses the percentage property as the primary property. The property is an integer with valid values from 0 to 100 inclusive. If you use the percentage property to represent a change, 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 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.

To let Alexa know the health of your device, also implement the Alexa.EndpointHealth interface.

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": "Unique identifier, preferably a version 4 UUID"
    },
    "payload": {
      "endpoints": [
        {
          "endpointId": "Unique ID of the endpoint",
          "manufacturerName": "Manufacturer of the endpoint",
          "description": "Description to be shown in the Alexa app",
          "friendlyName": "Device name, displayed in the Alexa app",
          "additionalAttributes":  {
            "manufacturer": "Manufacturer of the endpoint",
            "model" : "Model of the device",
            "customIdentifier": "Optional custom identifier for the device"
          },
          "displayCategories": ["OTHER"],
          "cookie": {},
          "capabilities": [
            {
              "type": "AlexaInterface",
              "interface": "Alexa.PercentageController",
              "version": "3",
              "properties": {
                "supported": [
                  {
                    "name": "percentage"
                  }
                ],
                "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

Alexa sends the following Alexa.PercentageController interface directives to your skill.

SetPercentage directive

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

The following examples show user utterances:

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

Alexa, stelle <Gerätename> auf dreißig Prozent.

Alexa, règle le salon à trente pour cent.

Alexa, {डिवाइस का नाम} को तीस प्रतिशत पर सेट करें।

Alexa, imposta il salotto al trenta percento.

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

Alexa, coloque a luz da cozinha em trinta por cento.
Alexa, ajusta a luz do quarto para trinta por cento.

Alexa, configura el dispositivo al treinta por ciento.

SetPercentage directive example

{
  "directive": {
    "header": {
      "namespace": "Alexa.PercentageController",
      "name": "SetPercentage",
      "messageId": "Unique version 4 UUID",
      "correlationToken": "Opaque correlation token",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "OAuth2.0 bearer token"
      },
      "endpointId": "Endpoint ID",
      "cookie": {}
    },
    "payload": {
      "percentage": 74
    }
  }
}

SetPercentage directive payload

The following table shows the payload details for the SetPercentage directive.

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

SetPercentage response

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.

The following example shows a SetPercentage response.

Copied to clipboard.

{
  "event": {
    "header": {
      "namespace": "Alexa",
      "name": "Response",
      "messageId": "Unique identifier, preferably a version 4 UUID",
      "correlationToken": "Opaque correlation token that matches the request",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "OAuth2.0 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 users can adjust the percentage value of a device setting.

The following examples show user utterances:

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

Alexa, erhöhe <Gerätename> um zehn Prozent.
Alexa, reduziere <Gerätename> um zwanzig Prozent.

Alexa, augmente le salon de dix pour cent.
Alexa, réduis le salon de vingt pour cent.

Alexa, {डिवाइस का नाम} को दस प्रतिशत बढ़ा दें।
Alexa, {डिवाइस का नाम} को बीस प्रतिशत घटाएं।

Alexa, aumenta il salotto del dieci percento.
Alexa, diminuisci il salotto del venti percento.

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

Alexa, aumente a luz da sala em dez por cento.
Alexa, aumente o brilho da luz da sala em dez por cento.
Alexa, diminua a luz da sala em dez por cento.
Alexa, diminua o brilho da luz da sala em dez por cento.

Alexa, sube la luz en un diez por ciento.
Alexa, disminuye la luz en un veinte por ciento.

AdjustPercentage directive payload

The following table shows the payload details for the AdjustPercentage directive.

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": "Unique version 4 UUID",
      "correlationToken": "Opaque correlation token",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "OAuth2.0 bearer token"
      },
      "endpointId": "Endpoint ID",
      "cookie": {}
    },
    "payload": {
      "percentageDelta": -20
    }
  }
}

AdjustPercentage response

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.

The following example shows a AdjustPercentage response.

Copied to clipboard.

{
  "event": {
    "header": {
      "namespace": "Alexa",
      "name": "Response",
      "messageId": "Unique identifier, preferably a version 4 UUID",
      "correlationToken": "Opaque correlation token that matches the request",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "OAuth2.0 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 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 example

Copied to clipboard.

{
  "event": {
    "header": {
      "namespace": "Alexa",
      "name": "StateReport",
      "messageId": "Unique identifier, preferably a version 4 UUID",
      "correlationToken": "Opaque correlation token that matches the request",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "OAuth2.0 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 report changes proactively 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": "Unique identifier, preferably a version 4 UUID",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "OAuth2.0 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": {
    "namespace": "Alexa.EndpointHealth",
    "name": "connectivity",
    "value": {
      "value": "OK"
    },
    "timeOfSample": "2017-02-03T16:20:50.52Z",
    "uncertaintyInMilliseconds": 0
  }
}

Was this page helpful?

Last updated: Nov 22, 2023