Alexa.ThermostatControllerインターフェース
ユーザーがスマートサーモスタットを制御できるように、Alexaスキルに Alexa.ThermostatController
インターフェイスを実装しましょう。サーモスタットでは、ヒーター、エアコン、シーリングファン、温水器などのデバイスを制御できます。スマートホームスキルの詳細については、スマートホームスキルAPIについてを参照してください。
サーモスタットは、温度を感知し、計測温度を所定の設定値や指定された温度範囲内に保持しようとするデバイスです。ThermostatController
インターフェースは、最大2つの設定値と各種サーモスタットモードを備えた、サーモスタットスケジュールのプログラムが可能なデバイスに使用できます。通常、ThermostatController
インターフェースは、Alexa.TemperatureSensorインターフェースと併せて使用します。
AlexaがサーモスタットデバイスまたはHVACシステムのエネルギー使用量を推定できるようにするには、 Alexa.ThermostatController.HVAC.Componentsインターフェースを実装します。
ThermostatController
インターフェースがサポートする言語については、Alexaインターフェースとサポートしている言語の一覧を参照してください。
発話
Alexa.ThermostatController
インターフェースを使用する場合、音声対話モデルは既にビルドされています。以下に、ユーザーの発話の例を示します。
アレクサ、サーモスタットを20に設定して
アレクサ、エアコンを24度に設定して
アレクサ、温度を上げて
アレクサ、温度を下げて
アレクサ、サーモスタットを自動に設定して
アレクサ、リビングのエアコンを自動モードにして
Alexa, set thermostat to twenty.
Alexa, set the AC to seventy-five.
Alexa, set the AC to twenty-five degrees for four hours.
Alexa, make it warmer in here.
Alexa, make it cooler in here.
Alexa, set thermostat to automatic.
Alexa, turn off the heat.
Alexa, resume thermostat schedule.
Alexa, what mode is my thermostat set to?
ユーザーがこのような発話をすると、Alexaがそれに対応するディレクティブまたは状態レポートリクエストをスキルに送信します。
サーモスタットの設定値の種類
Alexaは、1つまたは2つの温度値を設定できるサーモスタットをサポートします。
- 設定値が1つのサーモスタット
- 設定値が1つのサーモスタットの場合、サーモスタットが保持しようとする温度設定は1つです。たとえば、設定値が1つのサーモスタットは、温度が設定値よりも低くなると暖房をオンにし、温度が設定値よりも高くなると暖房をオフにします。
- 設定値が2つのサーモスタット
- 設定値が2つのサーモスタットには、上限と下限の設定値があります。サーモスタットは、この設定値の範囲内に温度を保持します。
サーモスタットは、モードに応じて異なる設定値に対応できます。詳細については、プロパティを参照してください。
サーモスタットのスケジューリング(日本未対応)
ユーザーは、温度を設定する際にリクエストの期間(保持時間)を指定できます。たとえば、「Alexa, set the thermostat to seventy-two degrees for thirty minutes.」のように言うことができます。 デバイスが保持時間をサポートしている場合は、そのことを検出応答で示します。
現状では、ユーザーは未来の時刻の温度やサーモスタットモードを設定するようリクエストすることはできません。
プロパティ
Alexa.ThermostatController
インターフェースは次のプロパティを定義します。
プロパティ | 説明 | 型 |
---|---|---|
targetSetpoint |
サーモスタットは、温度をこの設定値に保持しようとします。このプロパティは、設定値が1つのサーモスタットで使用します。 | Temperature |
lowerSetpoint |
サーモスタットは、温度をこの設定値より上に保持しようとします。このプロパティは、設定値が2つのサーモスタットで使用します。 | Temperature |
upperSetpoint |
サーモスタットは、温度をこの設定値より下に保持しようとします。このプロパティは、設定値が2つのサーモスタットで使用します。 | Temperature |
thermostatMode |
サーモスタットの現在のモードです。 | ThermostatMode |
サーモスタットは、モードに応じて異なる設定値に対応できます。たとえば、HEAT
またはCOOL
モードでサポートするのは目標値のみ、AUTO
またはECO
モードでサポートするのは下限値と上限値です。
検出
Alexa.ThermostatController
をサポートするエンドポイントは、Alexa.Discoveryの標準検出メカニズムを使用して表します。
Alexaからスキルに状態レポートリクエストが送信されたら、レポートするプロパティのretrievable
をtrueに設定します。変更レポートでAlexaにプロアクティブにレポートする場合はプロパティのproactivelyReported
をtrueに設定します。
表示カテゴリーにはTHERMOSTAT
を使用します。表示カテゴリーの一覧は、表示カテゴリーを参照してください。
configurationオブジェクト
ThermostatController
には、標準の検出応答フィールドのほかに、次のフィールドを含むconfigurationオブジェクトを含めます。
フィールド | 説明 | 型 | 必須 |
---|---|---|---|
supportedModes |
デバイスがサポートするモードです。 | thermostatMode文字列の配列 | ✕ |
supportsScheduling |
期間を示す設定値をユーザーが指定できる場合はtrueです。たとえば、ユーザーは温度を30分間、21度に設定できます。デフォルトはfalseです。現在、日本ではサポートされていません。 | ブール値 | ✕ |
検出応答の例
以下は、サーモスタットを制御し、Alexa.ThermostatController
インターフェースとAlexa.TemperatureSensorインターフェースをサポートするAlexaスキルのDiscover.Response
メッセージの例です。この例では、エンドポイントは設定値が2つのサーモスタットで、モードは3つ、スケジューリングはサポートしていません。
{
"event": {
"header": {
"namespace": "Alexa.Discovery",
"name": "Discover.Response",
"payloadVersion": "3",
"messageId": "<メッセージID>"
},
"payload": {
"endpoints": [
{
"endpointId": "<エンドポイントの一意のID>",
"manufacturerName": "エンドポイントのメーカー名",
"description": "サーモスタットメーカー製のスマートサーモスタット",
"friendlyName": "廊下のサーモスタット",
"displayCategories": ["THERMOSTAT", "TEMPERATURE_SENSOR"],
"additionalAttributes": {
"manufacturer": "<エンドポイントのメーカー名>",
"model" : "<デバイスのモデル>",
"serialNumber": "<デバイスのシリアル番号>",
"firmwareVersion" : "<デバイスのファームウェアバージョン>",
"softwareVersion": "<デバイスのソフトウェアバージョン>",
"customIdentifier": "<デバイスのカスタム識別子>"
},
"cookie": {},
"capabilities": [
{
"type": "AlexaInterface",
"interface": "Alexa.ThermostatController",
"version": "3",
"properties": {
"supported": [
{
"name": "lowerSetpoint"
},
{
"name": "upperSetpoint"
},
{
"name": "thermostatMode"
}
],
"proactivelyReported": true,
"retrievable": true
},
"configuration": {
"supportedModes": [ "HEAT", "COOL", "AUTO" ],
"supportsScheduling": false
}
},
{
"type": "AlexaInterface",
"interface": "Alexa.TemperatureSensor",
"version": "3",
"properties": {
"supported": [
{
"name": "temperature"
}
],
"proactivelyReported": true,
"retrievable": true
}
},
{
"type": "AlexaInterface",
"interface": "Alexa",
"version": "3"
}
]
}
]
}
}
}
エアコン用の検出応答の例
通常、エアコンがサポートする設定値は1つだけで、モードは冷房のみです。サーモスタットは一般的に常時オンですが、エアコンはユーザーがオンとオフを切り替えます。エアコンの場合には、Alexa.PowerControllerインターフェースも実装し、次のようにしてPowerController
とThermostatController
を同期することをお勧めします。
- サーモスタットのコントローラーモードが
COOL
に設定されたら、電源コントローラーの電源状態をON
にする。 - サーモスタットのコントローラーモードが
OFF
に設定されたら、電源コントローラーの電源状態をOFF
にする。
以下は、エアコンを制御し、ThermostatController
インターフェースとPowerControllerインターフェースをサポートするAlexaスキルのDiscover.Response
メッセージの例です。エアコンに温度を表示する場合を除き、Alexa.TemperatureSensorインターフェースの実装は不要です。
{
"event": {
"header": {
"namespace": "Alexa.Discovery",
"name": "Discover.Response",
"payloadVersion": "3",
"messageId": "<メッセージID>"
},
"payload": {
"endpoints": [
{
"endpointId": "<エンドポイントの一意のID>",
"manufacturerName": "エンドポイントのメーカー名",
"description": "スマートエアコン",
"friendlyName": "リビングのエアコン",
"displayCategories": ["THERMOSTAT", "TEMPERATURE_SENSOR"],
"additionalAttributes": {
"manufacturer": "<エンドポイントのメーカー名>",
"model" : "<デバイスのモデル>",
"serialNumber": "<デバイスのシリアル番号>",
"firmwareVersion" : "<デバイスのファームウェアバージョン>",
"softwareVersion": "<デバイスのソフトウェアバージョン>",
"customIdentifier": "<デバイスのカスタム識別子>"
},
"cookie": {},
"capabilities": [
{
"type": "AlexaInterface",
"interface": "Alexa.ThermostatController",
"version": "3",
"properties": {
"supported": [
{
"name": "targetSetpoint"
},
{
"name": "thermostatMode"
}
],
"proactivelyReported": true,
"retrievable": true
},
"configuration": {
"supportedModes": ["OFF", "COOL"],
"supportsScheduling": false
}
},
{
"type": "AlexaInterface",
"interface": "Alexa.PowerController",
"version": "3",
"properties": {
"supported": [
{
"name": "powerState"
}
],
"proactivelyReported": true,
"retrievable": true
}
},
{
"type": "AlexaInterface",
"interface": "Alexa",
"version": "3"
}
]
}
]
}
}
}
ディレクティブ
SetTargetTemperatureディレクティブ
SetTargetTemperature
ディレクティブをサポートすると、サーモスタットに保持させたい温度をユーザーが設定できます。ユーザーは、オプションで新たな温度設定の期間を指定できます。
以下に、ユーザーの発話の例を示します。
アレクサ、寝室のサーモスタットを20に設定して
アレクサ、リビングのエアコンを24度に設定して
Alexa, set bedroom thermostat to twenty.
Alexa, set living room air conditioner to seventy-five.
Alexa, set the kitchen AC to twenty-five degrees for four hours.
SetTargetTemperatureディレクティブペイロードの詳細
フィールド | 説明 | 型 |
---|---|---|
targetSetpoint |
サーモスタットは、温度をこの設定値に保持しようとします。ディレクテブには、設定値が1つのサーモスタット用に、このフィールドが含まれます。 | temperatureオブジェクト |
lowerSetpoint |
サーモスタットは、温度をこの設定値より上に保持しようとします。ディレクテブには、設定値が2つのサーモスタット用に、このフィールドが含まれます。 | temperatureオブジェクト |
upperSetpoint |
サーモスタットは、温度をこの設定値より下に保持しようとします。ディレクテブには、設定値が2つのサーモスタット用に、このフィールドが含まれます。 | temperatureオブジェクト |
schedule |
サーモスタットが指定された設定値を保持する必要のある期間です。指定された期間で、新しい設定値が直ちに適用されます。このフィールドは、ユーザーが指定した場合にのみ含まれます(検出応答でサポートを示している必要があります)。現状では、ユーザーは未来の時刻の温度を設定するようリクエストすることはできません。 | timeIntervalオブジェクト |
SetTargetTemperatureディレクティブの例(設定値が1つのサーモスタット)
次の例は、Alexaがスキルに送信するSetTargetTemperature
ディレクティブを示しています。
{
"directive": {
"header": {
"namespace": "Alexa.ThermostatController",
"name": "SetTargetTemperature",
"messageId": "<メッセージID>",
"correlationToken": "<opaque相関トークン>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<OAuth2ベアラートークン>"
},
"endpointId": "<エンドポイントID>",
"cookie": {}
},
"payload": {
"targetSetpoint": {
"value": 20.0,
"scale": "CELSIUS"
}
}
}
}
SetTargetTemperatureディレクティブの例(設定値が1つで、スケジュールあり)
以下の例は、Alexaがスキルに送信してスケジュールをリクエストする SetTargetTemperature
ディレクティブを示しています。
{
"directive": {
"header": {
"namespace": "Alexa.ThermostatController",
"name": "SetTargetTemperature",
"messageId": "<メッセージID>",
"correlationToken": "<opaque相関トークン>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<OAuth2ベアラートークン>"
},
"endpointId": "<エンドポイントID>",
"cookie": {}
},
"payload": {
"targetSetpoint": {
"value": 21.0,
"scale": "CELSIUS"
},
"schedule": {
"start": "2017-06-22T21:35Z",
"duration": "PT25M"
}
}
}
}
SetTargetTemperatureディレクティブの例(設定値が2つのサーモスタット)
次の例は、設定値が2つのサーモスタット用にAlexaがスキルに送信する SetTargetTemperature
ディレクティブを示しています。
{
"directive": {
"header": {
"namespace": "Alexa.ThermostatController",
"name": "SetTargetTemperature",
"messageId": "<メッセージID>",
"correlationToken": "<opaque相関トークン>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<OAuth2ベアラートークン>"
},
"endpointId": "<エンドポイントID>",
"cookie": {}
},
"payload": {
"lowerSetpoint": {
"value": 68.0,
"scale": "FAHRENHEIT"
},
"upperSetpoint": {
"value": 72.0,
"scale": "FAHRENHEIT"
}
}
}
}
SetTargetTemperature応答イベント
SetTargetTemperature
ディレクティブを正しく処理したら、Alexa.Responseイベントを使用して応答します。contextオブジェクトに、関連するすべてのプロパティの値を含めます。
SetTargetTemperature応答イベントの例(設定値が1つのサーモスタット)
{
"event": {
"header": {
"namespace": "Alexa",
"name": "Response",
"messageId": "<メッセージID>",
"correlationToken": "<opaque相関トークン>",
"payloadVersion": "3"
},
"endpoint": {
"endpointId": "<エンドポイントID>"
},
"payload": {}
},
"context": {
"properties": [
{
"namespace": "Alexa.ThermostatController",
"name": "thermostatMode",
"value": "HEAT",
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.ThermostatController",
"name": "targetSetpoint",
"value": {
"value": 20.0,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.TemperatureSensor",
"name": "temperature",
"value": {
"value": 19.3,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 1000
}
]
}
}
SetTargetTemperature応答イベントの例(設定値が2つのサーモスタット)
{
"event": {
"header": {
"namespace": "Alexa",
"name": "Response",
"messageId": "<メッセージID>",
"correlationToken": "<opaque相関トークン>",
"payloadVersion": "3"
},
"endpoint": {
"endpointId": "<エンドポイントID>"
},
"payload": {}
},
"context": {
"properties": [
{
"namespace": "Alexa.ThermostatController",
"name": "thermostatMode",
"value": "AUTO",
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.ThermostatController",
"name": "lowerSetpoint",
"value": {
"value": 68.0,
"scale": "FAHRENHEIT"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.ThermostatController",
"name": "upperSetpoint",
"value": {
"value": 72.0,
"scale": "FAHRENHEIT"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.TemperatureSensor",
"name": "temperature",
"value": {
"value": 66.5,
"scale": "FAHRENHEIT"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 1000
}
]
}
}
SetTargetTemperatureディレクティブのエラー処理
SetTargetTemperature
ディレクティブを正しく処理できなかった場合は、Alexa.ThermostatController.ErrorResponseイベントを使用して応答します。温度やサーモスタット特有のエラーではない場合は、汎用のAlexa.ErrorResponseイベントを使用して応答することもできます。
AdjustTargetTemperatureディレクティブ
AdjustTargetTemperature
ディレクティブをサポートすると、サーモスタットに保持させたい温度をユーザーが調整できます。
以下に、ユーザーの発話の例を示します。
Alexa, make it warmer in here.
Alexa, make it cooler in here.
AdjustTargetTemperatureディレクティブペイロードの詳細
フィールド | 説明 | 型 |
---|---|---|
targetSetpointDelta |
温度の変化量です。変化量は正でも負でもかまいません。 | temperatureオブジェクト |
AdjustTargetTemperatureディレクティブの例
以下の例は、Alexaがスキルに送信するAdjustTargetTemperature
ディレクティブを示しています。
{
"directive": {
"header": {
"namespace": "Alexa.ThermostatController",
"name": "AdjustTargetTemperature",
"messageId": "<メッセージID>",
"correlationToken": "<opaque相関トークン>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<OAuth2ベアラートークン>"
},
"endpointId": "<エンドポイントID>",
"cookie": {}
},
"payload": {
"targetSetpointDelta": {
"value": -2.0,
"scale": "CELSIUS"
}
}
}
}
AdjustTargetTemperature応答イベント
AdjustTargetTemperature
ディレクティブを正しく処理したら、Alexa.Responseイベントを使用して応答します。contextオブジェクトに、関連するすべてのプロパティの値を含めます。
AdjustTargetTemperature応答イベントの例
{
"event": {
"header": {
"namespace": "Alexa",
"name": "Response",
"messageId": "<メッセージID>",
"correlationToken": "<opaque相関トークン>",
"payloadVersion": "3"
},
"endpoint": {
"endpointId": "<エンドポイントID>"
},
"payload": {}
},
"context": {
"properties": [
{
"namespace": "Alexa.ThermostatController",
"name": "thermostatMode",
"value": "HEAT",
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.ThermostatController",
"name": "targetSetpoint",
"value": {
"value": 18.0,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.TemperatureSensor",
"name": "temperature",
"value": {
"value": 20.0,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 1000
}
]
}
}
AdjustTargetTemperatureディレクティブのエラー処理
AdjustTargetTemperature
ディレクティブを正しく処理できなかった場合は、Alexa.ThermostatController.ErrorResponseイベントを使用して応答します。温度やサーモスタット特有のエラーではない場合は、汎用のAlexa.ErrorResponseイベントを使用して応答することもできます。
SetThermostatModeディレクティブ
SetThermostatMode
ディレクティブをサポートすると、ユーザーがデバイスのモードを設定できます。ユーザーは「アレクサ、<ユーザーのサーモスタットデバイス名>を<利用可能なモード>にして」のように発話する必要があります。
以下に、ユーザーの発話の例を示します。
アレクサ、サーモスタットを自動に設定して
アレクサ、リビングのエアコンを自動モードにして
Alexa, set living room thermostat to automatic.
SetThermostatModeディレクティブペイロードの詳細
フィールド | 説明 | 型 |
---|---|---|
thermostatMode |
サーモスタットに設定するモードです。 | thermostatModeオブジェクト |
SetThermostatModeディレクティブの例
次の例は、Alexaがスキルに送信するSetThermostatMode
ディレクティブを示しています。
{
"directive": {
"header": {
"namespace": "Alexa.ThermostatController",
"name": "SetThermostatMode",
"messageId": "<メッセージID>",
"correlationToken": "<opaque相関トークン>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<OAuth2ベアラートークン>"
},
"endpointId": "<エンドポイントID>",
"cookie": {}
},
"payload": {
"thermostatMode" : {
"value": "COOL"
}
}
}
}
SetThermostatMode応答イベント
SetThermostatMode
ディレクティブを正しく処理したら、Alexa.Responseイベントを使用して応答します。contextオブジェクトに、関連するすべてのプロパティの値を含めます。
SetThermostatMode応答イベントの例
{
"event": {
"header": {
"namespace": "Alexa",
"name": "Response",
"messageId": "<メッセージID>",
"correlationToken": "<opaque相関トークン>",
"payloadVersion": "3"
},
"endpoint": {
"endpointId": "<エンドポイントID>"
},
"payload": {}
},
"context": {
"properties": [
{
"namespace": "Alexa.ThermostatController",
"name": "thermostatMode",
"value": "COOL",
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.ThermostatController",
"name": "targetSetpoint",
"value": {
"value": 17.0,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.TemperatureSensor",
"name": "temperature",
"value": {
"value": 19.0,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 1000
}
]
}
}
SetThermostatModeディレクティブのエラー処理
SetThermostatMode
ディレクティブを正しく処理できなかった場合は、Alexa.ThermostatController.ErrorResponseイベントを使用して応答します。温度やサーモスタット特有のエラーではない場合は、汎用のAlexa.ErrorResponseイベントを使用して応答することもできます。
ResumeScheduleディレクティブ
ResumeSchedule
ディレクティブをサポートすると、ユーザーはサーモスタットにプログラムされているスケジュールを上書きした後に再開できます。たとえば、家を空けている間は休暇中用の上書き設定を使用し、帰ってきたら通常のプログラムを再開する、という使い方ができます。
以下に、ユーザーの発話の例を示します。
Alexa, resume living room thermostat schedule.
ResumeScheduleディレクティブの例
次の例は、Alexaがスキルに送信するResumeSchedule
ディレクティブを示しています。
{
"directive": {
"header": {
"namespace": "Alexa.ThermostatController",
"name": "ResumeSchedule",
"messageId": "<メッセージID>",
"correlationToken": "<opaque相関トークン>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<OAuth2ベアラートークン>"
},
"endpointId": "<エンドポイントID>",
"cookie": {}
},
"payload": {}
}
}
ResumeSchedule応答イベント
ResumeSchedule
ディレクティブを正しく処理したら、Alexa.Responseイベントを使用して応答します。contextオブジェクトに、関連するすべてのプロパティの値を含めます。
ResumeSchedule応答イベントの例
{
"event": {
"header": {
"namespace": "Alexa",
"name": "Response",
"messageId": "<メッセージID>",
"correlationToken": "<opaque相関トークン>",
"payloadVersion": "3"
},
"endpoint": {
"endpointId": "<エンドポイントID>"
},
"payload": {}
},
"context": {
"properties": [
{
"namespace": "Alexa.ThermostatController",
"name": "thermostatMode",
"value": "HEAT",
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.ThermostatController",
"name": "targetSetpoint",
"value": {
"value": 18.0,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.TemperatureSensor",
"name": "temperature",
"value": {
"value": 17.9,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 1000
}
]
}
}
ResumeScheduleディレクティブのエラー処理
ResumeSchedule
ディレクティブを正しく処理できなかった場合は、Alexa.ThermostatController.ErrorResponseイベントを使用して応答します。温度やサーモスタット特有のエラーではない場合は、汎用のAlexa.ErrorResponseイベントを使用して応答することもできます。
状態レポート
Alexaはエンドポイントの状態についての情報をリクエストするために、ReportState
ディレクティブを送信します。AlexaがReportState
ディレクティブを送信したら、それに対する応答としてStateReport
イベントを送信します。応答には、contextオブジェクトのすべてのretrievableプロパティの現在の状態を含めます。retrievableプロパティは検出応答で特定します。状態レポートの詳細については、状態および変更レポートについてを参照してください。
StateReport応答イベントの例
{
"event": {
"header": {
"namespace": "Alexa",
"name": "StateReport",
"messageId": "<メッセージID>",
"correlationToken": "<opaque相関トークン>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<OAuth2ベアラートークン>"
},
"endpointId": "<エンドポイントID>"
},
"payload": {}
},
"context": {
"properties": [
{
"namespace": "Alexa.ThermostatController",
"name": "thermostatMode",
"value": "HEAT",
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.ThermostatController",
"name": "targetSetpoint",
"value": {
"value": 20.0,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.TemperatureSensor",
"name": "temperature",
"value": {
"value": 19.9,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 1000
}
]
}
}
エアコン用のStateReport応答イベントの例
{
"event": {
"header": {
"namespace": "Alexa",
"name": "StateReport",
"messageId": "<メッセージID>",
"correlationToken": "<opaque相関トークン>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<OAuth2ベアラートークン>"
},
"endpointId": "<エンドポイントID>"
},
"payload": {}
},
"context": {
"properties": [
{
"namespace": "Alexa.ThermostatController",
"name": "thermostatMode",
"value": "COOL",
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.ThermostatController",
"name": "targetSetpoint",
"value": {
"value": 20.0,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.PowerController",
"name": "powerState",
"value": "ON",
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
}
]
}
}
変更レポート
エンドポイントの状態の変化をプロアクティブにレポートするために、ChangeReport
イベントを送信します。プロアクティブにレポートするプロパティは検出応答で特定します。変更レポートの詳細については、状態および変更レポートについてを参照してください。
ChangeReportイベントの例
{
"event": {
"header": {
"namespace": "Alexa",
"name": "ChangeReport",
"messageId": "<メッセージID>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<OAuth2ベアラートークン>"
},
"endpointId": "<エンドポイントID>"
},
"payload": {
"change": {
"cause": {
"type": "PHYSICAL_INTERACTION"
},
"properties": [
{
"namespace": "Alexa.ThermostatController",
"name": "thermostatMode",
"value": "COOL",
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.ThermostatController",
"name": "targetSetpoint",
"value": {
"value": 18.0,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.TemperatureSensor",
"name": "temperature",
"value": {
"value": 19.1,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 1000
}
]
}
}
},
"context": {}
}
エアコン用のChangeReportイベントの例
{
"event": {
"header": {
"namespace": "Alexa",
"name": "ChangeReport",
"messageId": "<メッセージID>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<OAuth2ベアラートークン>"
},
"endpointId": "<エンドポイントID>"
},
"payload": {
"change": {
"cause": {
"type": "PHYSICAL_INTERACTION"
},
"properties": [
{
"namespace": "Alexa.ThermostatController",
"name": "thermostatMode",
"value": "COOL",
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.ThermostatController",
"name": "targetSetpoint",
"value": {
"value": 18.0,
"scale": "CELSIUS"
},
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
},
{
"namespace": "Alexa.PowerController",
"name": "powerState",
"value": "ON",
"timeOfSample": "2017-02-03T16:20:50.52Z",
"uncertaintyInMilliseconds": 500
}
]
}
}
},
"context": {}
}
ユーザー確認の要求
ja-JP
ロケールでのみサポートされています。ユーザーが温度を設定したり、サーモスタットのモード変更を指示した場合に、必要に応じてAlexaが実行する前にアクションを確認するようユーザーに要求できます。ユーザー確認を求めるには、Discover.Response
で確認を要求するディレクティブを指定します。詳細については、 verificationsRequiredオブジェクト と ユーザー確認を求めるサーモスタットの例を参照してください。
次に、ユーザ確認が必要な場合の会話の例を示します。
アレクサ、リビングのエアコンを25度にして。
リビングのエアコンで、設定温度を25度にするんですね?
はい。
リビングのエアコンを冷房25度に設定しました。
Alexa, set the temperature to 65 degrees on the living room air conditioner.
Set living room air conditioner to 65 degrees?
Yes.
OK, living room air conditioner is set to 65 degrees.