Alexa.TemperatureSensorインターフェース
Alexa.TemperatureSensor
インターフェース機能は、温度を感知するエンドポイントに割り当てることができます。このインターフェースではディレクティブやイベントを定義しませんが、StateReport
イベントを使ってReportState
ディレクティブに応答します。
TemperatureSensor
インターフェースでサポートされているロケールについては、機能インターフェースの一覧を参照してください。
検出
Alexa.TemperatureSensor
をサポートするエンドポイントは、Alexa.Discoveryの標準検出メカニズムを使用して表します。
表示カテゴリーにはTHERMOSTAT
を使用します。表示カテゴリーの一覧は、表示カテゴリーを参照してください。
応答例
以下は、Alexa.TemperatureSensor
インターフェースとAlexa.ThermostatController
インターフェースをサポートする1つのエンドポイントへのDiscover.Response
メッセージの例です。
{
"event": {
"header": {
"namespace": "Alexa.Discovery",
"name": "Discover.Response",
"payloadVersion": "3",
"messageId": "<メッセージID>"
},
"payload": {
"endpoints":[
{
"endpointId": "<エンドポイントの一意のID>",
"manufacturerName": "<エンドポイントのメーカー名>",
"modelName": "<エンドポイントのモデル名>",
"friendlyName": "廊下のサーモスタット",
"description": "<Alexaアプリに表示される説明>",
"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
}
}
]
}
]
}
}
}
ディレクティブ
このインターフェースはAlexaからのエンドポイントの状態リクエストに応答します。
ReportState
ReportState
ディレクティブは、エンドポイントの状態をリクエストするために送信されます。エンドポイント(この場合はappliance-001
)がメッセージで指定されます。
ReportStateリクエストの例
{
"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": {
}
}
}
プロパティとイベント
このインターフェースでは、以下のように応答できます。
- スキルのLambda関数から
StateReport
ディレクティブと同期をとって応答します。 - 非同期的に
ChangeReport
イベントをAlexaイベントゲートウェイに送信します。非同期的に応答する場合、認可トークンにscope
を含めてユーザーを識別し、相関トークンを含めて応答先のディレクティブを識別する必要があります。
プロパティ
プロパティ名 | 型 | 説明 |
---|---|---|
temperature |
Temperature | エンドポイントの温度です。温度の値と尺度の単位を含みます。 |
StateReportイベント
エンドポイントの状態をレポートします。
StateReportの例
{
"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": {}
}
}
その他のサンプルコード
リクエストと応答のサンプルについては、AlexaスマートホームのGitHubリポジトリで以下を参照してください。
関連インターフェース
インターフェース | 説明 |
---|---|
Alexa.ThermostatController | サーモスタットエンドポイントの設定変更に関連するディレクティブとイベントについて説明します。 |