Generic Controller Interfaces
Generic controller interfaces are general-purpose interfaces that you can use to model different components of a smart home device in your Alexa skills. For details about smart home skills, see Understand the Smart Home Skill API.
Currently, the generic controller interfaces are the following:
- ModeController — model properties of a device that can be set to one of a list of values.
- RangeController — model properties of a device that can be set to one of a range of values.
- ToggleController — model properties of a device that can be set to on or off.
Usually you choose the most specific controller available to model components of your devices, because the more specific the controller, the more natural the utterances are for your user. However, the generic controllers provide some benefits not available with more specific controllers, such as the ability to implement multiple instances of a controller for a single device, and support for semantics.
Correspondence of specific and generic controllers
The following table lists the generic controllers, and examples of corresponding specific controllers, that you can use to model components of your devices.
|Generic Controllers||Corresponding Specific Controllers|
When you implement a specific controller interface in the Alexa skill for your device, you can only implement one instance of the interface. When you implement a generic controller interface in your Alexa skill, you can implement multiple instances of the controller. You specify an
instance name for each instance of the controller in the discover response for your skill. For details and sample code, see the documentation for each generic interface.
The following scenarios are examples of implementing multiple instances of generic controllers:
For a washing machine device, implement one instance of the ModeController interface named
Washer.WashCycleto model the wash cycle. Implement a second instance of the ModeController interface named
Washer.WashTemperatureto model the water temperature.
For a ceiling fan with a light, implement one instance of the RangeController interface named
Fan.Speedto model the fan speed. Implement a second instance of the RangeController interface named
Fan.Lightto model the brightness of the light.
For a stove with a cooktop and an oven, implement one instance of the ToggleController interface named
Oven.Lightto model the oven light. Implement a second instance of the ToggleController interface named
Stovetop.ResidualHeatto model the safety feature that warns users when there is residual heat and the stovetop is too hot to touch.
Both specific and generic controllers use a pre-built voice-interaction model, which means that when you use them, the utterances that users say to Alexa are already defined for you. Usually you choose the most specific controller available to model components of your devices, because the more specific the controller, the more natural the utterances are for your user.
The following table compares utterances for generic controllers and specific controllers. In these examples, a generic controller is used for the same device as a specific controller. For the generic controllers, the user must say the name of the instance, or a friendly name replacement for it, in the utterance.
|Example Device||Generic Controller Utterances||Specific Controller Utterances|
|A smart thermostat with a mode named automatic. The user named the thermostat "Bedroom Thermostat" in the Alexa app.||If you model the thermostat with ModeController:
"Alexa, set the Thermostat Mode on the Bedroom Thermostat to automatic."
|If you model the thermostat with ThermostatController:
"Alexa, set the Bedroom Thermostat to automatic."
|A speaker that controls volume on a smart television. The user named the television "Living Room TV" in the Alexa app.||If you model the volume with RangeController:
"Alexa, turn Speaker Volume down on the Living Room TV."
|If you model the volume with Speaker:
"Alexa, turn the volume down on the Living Room TV."
|A smart plug. The user plugged a portable heater into the plug and named the plug "Desk Heater" in the Alexa app.||If you model the power with ToggleController:
"Alexa, turn on the Desk Heater."
|If you model the power with PowerController:
"Alexa, turn on the Desk Heater."
Use semantics to enable additional features, such as additional user utterances. To use semantics, include a semantics object in your discover response.
Semantics for user utterances
When you implement generic controllers you can optionally enable additional utterances for your users by using semantics. When you use semantics, you manually map the phrases "open", "close", "raise", and "lower" to the directives of your controller. For example, if you have a
ToggleController for a garbage can lid, you can map the phrase "open" to the
TurnOn directive. For details and sample code, see the documentation for each generic interface.
ModeControllerinstance, you can't map the phrase
openon any other
RangeControllerinstances, or any
The following examples show some user utterances that use semantics:
Alexa, open the garage door.
Alexa, close the garbage can lid.
Alexa, raise the bedroom blinds.
Alexa, lower the living room blinds.
Semantics for Alexa hunches
You can use semantics to enable Alexa hunches for your device to conserve energy on behalf of users. For details about hunches, see What Are Alexa Hunches? and Enable Alexa to Proactively Act on Hunches Without Customers Needing to Ask.
The semantics for Alexa hunches are
Alexa.States.EcoOff. For an example discovery response that includes support for Alexa hunches, see discovery response example for a water heater.