---
# System prepended metadata

title: Alex Skill Controller
tags: [Alexa]

---

# Alex Skill Controller

## [Alexa.ModeController](https://developer.amazon.com/de-DE/docs/alexa/device-apis/alexa-modecontroller.html)
*	Alexa 技能中實現Alexa.ModeController界面，用戶可以控制設備的模式設置。
*	使用該Alexa.ModeController界面對設備的屬性進行建模，用戶可以將其設置為一系列值，例如洗衣機的洗滌循環模式。
*	值列表可以有順序，但這不是必需的。該Alexa.ModeController接口是一個通用控制器接口。

### Properties
**Mode 屬性**
*	```Alexa.ModeController```接口使用該mode屬性作為主要屬性。
*	屬性值是字符串。該Mode對象定義模式的可接受值。
*	一個端點可以支持多種模式。
*	要區分模式，必須始終包含該instance屬性。


### SetMode 指令
```json
{
  "directive": {
    "header": {
      "namespace": "Alexa.ModeController",
      "instance": "Washer.WashCycle",
      "name": "SetMode",
      "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": {
      "mode": "WashCycle.Normal"
    }
  }
}
```
### 回應
```json
{
  "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.ModeController",
        "instance": "Washer.WashCycle",
        "name": "mode",
        "value": "WashCycle.Normal",
        "timeOfSample": "2017-02-03T16:20:50Z",
        "uncertaintyInMilliseconds": 0
      }
    ]
  }
}
```


## [Alexa.PowerController](https://developer.amazon.com/de-DE/docs/alexa/device-apis/alexa-powercontroller.html)

### Properties
**powerState 屬性**
*	```Alexa.PowerController```使用 powerState 屬性作為主要屬性。
*	有效值為 ON 或 OFF。

### TurnOn 指令
```json
{
  "directive": {
    "header": {
      "namespace": "Alexa.PowerController",
      "name": "TurnOn",
      "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": {}
  }
}
```

### TurnOn回應
```json
{
  "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.PowerController",
        "name": "powerState",
        "value": "ON",
        "timeOfSample": "2017-02-03T16:20:50.52Z",
        "uncertaintyInMilliseconds": 500
      }
    ]
  }
}
```


## [Alexa.PowerLevelController](https://developer.amazon.com/de-DE/docs/alexa/device-apis/alexa-powerlevelcontroller.html)

### Properties
**powerLevel 屬性**
*	```Alexa.PowerLevelController```使用該powerLevel屬性作為主要屬性。
*	該屬性表示設備的功率級別，以介於 0 和 100 之間的整數百分比表示。
*	如果該powerLevel屬性用於表示更改，則有效值為 -100 到 100（含）。

### SetPowerLevel 指令
```json
{
  "directive": {
    "header": {
      "namespace": "Alexa.PowerLevelController",
      "name": "SetPowerLevel",
      "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": {
      "powerLevel": 40
    }
  }
}
```

### SetPowerLevel回應
```json
{
  "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.PowerLevelController",
        "name": "powerLevel",
        "value": 40,
        "timeOfSample": "2017-02-03T16:20:50.52Z",
        "uncertaintyInMilliseconds": 500
      }
    ]
  }
}
```

## [Alexa.SceneController](https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-scenecontroller.html)

*	Alexa 技能中實現該```Alexa.SceneController```界面，以便用戶可以激活或停用組合成一個場景的多個智能家居設備。
*	場景將設備組合設置為每個設備的特定狀態。根據狀態變化的發生方式對場景進行分類：
	*	**活動觸發** - 狀態更改必須以特定順序發生。例如，對於名為「觀看 Netflix」的場景，您可以先打開電視電源，然後將輸入設置為 HDMI1。
	*	**場景觸發** — 狀態變化可以以任何順序發生。例如，對於名為“就寢時間”的場景，您可以按任意順序關閉燈光並降低恆溫器。

*	通常，用戶使用與 Alexa 兼容的集線器或通過設備製造商的應用程序編輯和創建場景。您還可以創建提供場景的 Alexa 技能。

### 支援的裝置種類
*	You can support the following device types in your skill for a scene:

1. Fans
2. Light bulbs
3. Speakers
4. Switched electrical outlets
5. Thermostats
6. TVs
7. Window blinds

*	You can't support the following device types in your skill for a scene:

1. Cameras
1. Cooking appliances
1. Door locks
1. Garage doors
1. Security sensors
1. Security systems

### Discover response example

在您的發現響應中，您必須為支持的端點配置端點信息，Alexa.SceneController如下所示：

* 使用`endpointId`來識別場景而**不是**物理設備。
* 在該`description`字段中，包括`scene`一詞並描述場景如何連接。例如，按供應商名稱連接的派對場景。
* 包括該friendlyName字段。用戶使用友好名稱與您的場景進行交互。請遵循以下準則來定義friendlyName字段：
	* 僅包括場景名稱。此名稱為用戶與場景交互提供了最簡單、最自然的方式。
	* 如果您在不同的房間提供類似的場景，可以選擇包含房間名稱。
	* (可選) 包括`scene`一詞。
	* (可選) 在場景名稱和房間名稱之間包含單詞`in`。
	* **不要**包含特殊字符或標點符號。
	* **不要**超過 128 個字符。
*	設置`displayCategories`為`ACTIVITY_TRIGGER`或`SCENE_TRIGGER`。有關顯示類別的完整列表，請參閱顯示[類別](https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-discovery.html#display-categories)。

以下示例顯示了`Discover.Response`支持該`Alexa.SceneController`接口的設備的消息。
```json
{
    "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 scene",
                "manufacturerName": "Sample Vendor",
                "description": "Party scene by Sample Vendor",
                "friendlyName": "Living Room Party",
                "displayCategories": ["SCENE_TRIGGER"],
                "cookie": {},
                "capabilities": [{
                        "type": "AlexaInterface",
                        "interface": "Alexa.SceneController",
                        "version": "3",
                        "supportsDeactivation": false
                    },
                    {
                        "type": "AlexaInterface",
                        "interface": "Alexa",
                        "version": "3"
                    }
                ]
            }]
        }
    }
}
```

### Activate directive指令
```json
{
    "directive": {
        "header": {
            "namespace": "Alexa.SceneController",
            "name": "Activate",
            "messageId": "Unique version 4 UUID",
            "correlationToken": "Opaque correlation token",
            "payloadVersion": "3"
        },
        "endpoint": {
            "scope": {
                "type": "BearerToken",
                "token": "OAuth2.0 bearer token"
            },
            "endpointId": "endpoint id"
        },
        "payload": {}
    }
}
```

### ActivationStarted event 回應
```json
{
    "event": {
        "header": {
            "namespace": "Alexa.SceneController",
            "name": "ActivationStarted",
            "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": {
            "cause": {
                "type": "VOICE_INTERACTION"
            },
            "timestamp": "2017-02-03T16:20:50Z"
        }
    },
    "context": {}
}
```


## [Alexa.RangeController](https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-rangecontroller.html)
*	在 Alexa 技能中實現該```Alexa.RangeController```界面，以便用戶可以在最小和最大範圍內控制由數字表示的設備設置。
*	使用該```Alexa.RangeController```界面對設備的屬性進行建模，用戶可以將其設置為一系列值之一，例如攪拌機或風扇的速度設置。

### Properties
**RangeValue 屬性**
*	該```Alexa.RangeController```接口使用該```rangeValue```屬性作為主要屬性。
*	屬性值是數字，您可以在發現響應中指定最小值、最大值和精度。
*	如果您使用該rangeValue屬性來表示更改，則有效值包括負數。


### SetRangeValue 指令
```json
{
  "directive": {
    "header": {
      "namespace": "Alexa.RangeController",
      "instance": "Fan.Speed",
      "name": "SetRangeValue",
      "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": {
      "rangeValue": 7
    }
  }
}
```

### SetRangeValue 回應
```json
{
  "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.RangeController",
        "instance": "Fan.Speed",
        "name": "rangeValue",
        "value": 7,
        "timeOfSample": "2017-02-03T16:20:50.52Z",
        "uncertaintyInMilliseconds": 500
      }
    ]
  }
}
```
## 文件
[Alexa.RangeController](https://developer.amazon.com/en-US/docs/alexa/alexa-voice-service/alexa-rangecontroller.html)
[Alexa.ModeController](https://developer.amazon.com/en-US/docs/alexa/alexa-voice-service/alexa-modecontroller.html)


###### tags: `Alexa`