Merci de votre visite. Cette page est disponible en anglais uniquement.

Alexa.TemperatureSensor Interface

The Alexa.TemperatureSensor interface capability can be assigned to an endpoint that can sense temperature. This interface does not define any directives or events, but responds to a ReportState directive with a StateReport event.

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

Discovery

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

Use THERMOSTAT for the display category. 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.TemperatureSensor and Alexa.ThermostatController 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>",
                    "friendlyName": "Hallway Thermostat",
                    "description": "<a description that is shown in the Alexa app>",
                    "displayCategories": ["THERMOSTAT"],
                    "cookie": {},
                    "capabilities": [
                        {
                            "type": "AlexaInterface",
                            "interface": "Alexa.TemperatureSensor",
                            "version": "3",
                            "properties": {
                                "supported": [
                                    {
                                        "name": "temperature"
                                    }
                                ],
                                "proactivelyReported": true,
                                "retrievable": true
                            }
                        },
                        {
                            "type": "AlexaInterface",
                            "interface": "Alexa.ThermostatController",
                            "version": "3",
                            "properties": {
                              "supported": [
                                {
                                  "name": "lowerSetpoint"
                                },
                                {
                                  "name": "targetSetpoint"
                                },
                                {
                                  "name": "upperSetpoint"
                                },
                                {
                                  "name": "thermostatMode"
                                }
                              ],
                              "proactivelyReported": true,
                              "retrievable": true
                            }
                        }
                    ]
                }
            ]
        }
    }
}

Directives

This interface responds to Alexa's requests for endpoint state.

ReportState

A ReportState directive is sent to request the state of an endpoint. The endpoint appliance-001 in this case, is specified in the message.

Example ReportState Request

{
  "directive": {
    "header": {
      "messageId": "abc-123-def-456",
      "correlationToken": "abcdef-123456",
      "namespace": "Alexa",
      "name": "ReportState",
      "payloadVersion": "3"
    },
    "endpoint": {
      "endpointId": "appliance-001",
      "cookie": {},
      "scope":{  
            "type":"BearerToken",
            "token":"access-token-from-skill"
      }
    },
    "payload": {
    }
  }
}

Properties and Events

For this interface, you can reply:

  • Synchronously with a StateReport directive from the skill's Lambda function.
  • Asynchronously, which means you send ChangeReport events to the Alexa event gateway. When you reply asynchronously, you must include a scope with an authorization token to identify the customer, and a correlation token to identify the directive you are responding to.

Properties

Property Name Type Description
temperature Temperature A temperature for the endpoint that contains a temperature value and scale.

StateReport Event

Reports the state of the endpoint.

StateReport example

{
  "context": {
    "properties": [ {
      "namespace": "Alexa.TemperatureSensor",
      "name": "temperature",
      "value": {
        "value": 24.0,
        "scale": "CELSIUS"
      },
      "timeOfSample": "2017-02-03T16:20:50.52Z",
      "uncertaintyInMilliseconds": 1000
    } ]
  },
  "event": {
    "header": {
      "namespace": "Alexa",
      "name": "StateReport",
      "payloadVersion": "3",
      "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
      "correlationToken": "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg=="
    },
    "endpoint": {
      "endpointId": "appliance-001"
    },
    "payload": {}
  }
}

Additional Sample Code

See the sample request and response messages in the Alexa smart home GitHub repo:

TemperatureSensor

Interface Description
Alexa.ThermostatController Describes directives and events related to changing settings of a thermostat endpoint