1 """Alexa capabilities."""
3 from __future__
import annotations
5 from collections.abc
import Generator
28 AlarmControlPanelEntityFeature,
29 AlarmControlPanelState,
36 ATTR_SUPPORTED_FEATURES,
38 ATTR_UNIT_OF_MEASUREMENT,
59 API_THERMOSTAT_PRESETS,
64 from .errors
import UnsupportedProperty
65 from .resources
import (
66 AlexaCapabilityResource,
73 _LOGGER = logging.getLogger(__name__)
75 UNIT_TO_CATALOG_TAG = {
76 UnitOfTemperature.CELSIUS: AlexaGlobalCatalog.UNIT_TEMPERATURE_CELSIUS,
77 UnitOfTemperature.FAHRENHEIT: AlexaGlobalCatalog.UNIT_TEMPERATURE_FAHRENHEIT,
78 UnitOfTemperature.KELVIN: AlexaGlobalCatalog.UNIT_TEMPERATURE_KELVIN,
79 UnitOfLength.METERS: AlexaGlobalCatalog.UNIT_DISTANCE_METERS,
80 UnitOfLength.KILOMETERS: AlexaGlobalCatalog.UNIT_DISTANCE_KILOMETERS,
81 UnitOfLength.INCHES: AlexaGlobalCatalog.UNIT_DISTANCE_INCHES,
82 UnitOfLength.FEET: AlexaGlobalCatalog.UNIT_DISTANCE_FEET,
83 UnitOfLength.YARDS: AlexaGlobalCatalog.UNIT_DISTANCE_YARDS,
84 UnitOfLength.MILES: AlexaGlobalCatalog.UNIT_DISTANCE_MILES,
85 UnitOfMass.GRAMS: AlexaGlobalCatalog.UNIT_MASS_GRAMS,
86 UnitOfMass.KILOGRAMS: AlexaGlobalCatalog.UNIT_MASS_KILOGRAMS,
87 UnitOfMass.POUNDS: AlexaGlobalCatalog.UNIT_WEIGHT_POUNDS,
88 UnitOfMass.OUNCES: AlexaGlobalCatalog.UNIT_WEIGHT_OUNCES,
89 UnitOfVolume.LITERS: AlexaGlobalCatalog.UNIT_VOLUME_LITERS,
90 UnitOfVolume.CUBIC_FEET: AlexaGlobalCatalog.UNIT_VOLUME_CUBIC_FEET,
91 UnitOfVolume.CUBIC_METERS: AlexaGlobalCatalog.UNIT_VOLUME_CUBIC_METERS,
92 UnitOfVolume.GALLONS: AlexaGlobalCatalog.UNIT_VOLUME_GALLONS,
93 PERCENTAGE: AlexaGlobalCatalog.UNIT_PERCENT,
94 "preset": AlexaGlobalCatalog.SETTING_PRESET,
99 """Translate the unit of measurement to an Alexa Global Catalog keyword."""
100 unit: str = entity.attributes.get(
"unit_of_measurement",
"preset")
101 return UNIT_TO_CATALOG_TAG.get(unit, AlexaGlobalCatalog.SETTING_PRESET)
105 """Base class for Alexa capability interfaces.
107 The Smart Home Skills API defines a number of "capability interfaces",
108 roughly analogous to domains in Home Assistant. The supported interfaces
109 describe what actions can be performed on a particular device.
111 https://developer.amazon.com/docs/device-apis/message-guide.html
114 _resource: AlexaCapabilityResource |
None
115 _semantics: AlexaSemantics |
None
116 supported_locales: set[str] = {
"en-US"}
121 instance: str |
None =
None,
122 non_controllable_properties: bool |
None =
None,
124 """Initialize an Alexa capability."""
130 """Return the Alexa API name of this interface."""
131 raise NotImplementedError
134 """Return what properties this entity supports."""
138 """Return True if properties asynchronously reported."""
142 """Return True if properties can be retrieved."""
146 """Return True if non controllable."""
150 """Read and return a property.
152 Return value should be a dict, or raise UnsupportedProperty.
154 Properties can also have a timeOfSample and uncertaintyInMilliseconds,
155 but returning those metadata is not yet implemented.
160 """Applicable only to scenes."""
163 """Return True if the capability is proactively reported.
165 Set properties_proactively_reported() for proactively reported properties.
166 Applicable to DoorbellEventSource.
170 """Return the capability object.
172 Applicable to ToggleController, RangeController, and ModeController interfaces.
177 """Return the configuration object.
179 Applicable to the ThermostatController, SecurityControlPanel, ModeController,
180 RangeController, and EventDetectionSensor.
184 """Return the configurations object.
186 The plural configurations object is different that the singular configuration
187 object. Applicable to EqualizerController interface.
190 def inputs(self) -> list[dict[str, str]] | None:
191 """Applicable only to media players."""
194 """Return the semantics object.
196 Applicable to ToggleController, RangeController, and ModeController interfaces.
200 """Return the supportedOperations object."""
204 """Applicable only to CameraStreamController."""
207 """Serialize according to the Discovery API."""
208 result: dict[str, Any] = {
209 "type":
"AlexaInterface",
210 "interface": self.name(),
214 if (instance := self.instance)
is not None:
215 result[
"instance"] = instance
217 if properties_supported := self.properties_supported():
218 result[
"properties"] = {
219 "supported": properties_supported,
220 "proactivelyReported": self.properties_proactively_reported(),
221 "retrievable": self.properties_retrievable(),
224 if (proactively_reported := self.capability_proactively_reported())
is not None:
225 result[
"proactivelyReported"] = proactively_reported
227 if (non_controllable := self.properties_non_controllable())
is not None:
228 result[
"properties"][
"nonControllable"] = non_controllable
230 if (supports_deactivation := self.supports_deactivation())
is not None:
231 result[
"supportsDeactivation"] = supports_deactivation
233 if capability_resources := self.capability_resources():
234 result[
"capabilityResources"] = capability_resources
236 if configuration := self.configuration():
237 result[
"configuration"] = configuration
241 if configurations := self.configurations():
242 result[
"configurations"] = configurations
244 if semantics := self.semantics():
245 result[
"semantics"] = semantics
247 if supported_operations := self.supported_operations():
248 result[
"supportedOperations"] = supported_operations
250 if inputs := self.inputs():
251 result[
"inputs"] = inputs
253 if camera_stream_configurations := self.camera_stream_configurations():
254 result[
"cameraStreamConfigurations"] = camera_stream_configurations
259 """Return properties serialized for an API response."""
261 prop_name = prop[
"name"]
264 except UnsupportedProperty:
268 "Unexpected error getting %s.%s property from %s",
275 if prop_value
is None:
280 "namespace": self.
namename(),
282 "timeOfSample": dt_util.utcnow().strftime(DATE_FORMAT),
283 "uncertaintyInMilliseconds": 0,
285 if (instance := self.
instanceinstance)
is not None:
286 result[
"instance"] = instance
292 """Implements Alexa Interface.
294 Although endpoints implement this interface implicitly,
295 The API suggests you should explicitly include this interface.
297 https://developer.amazon.com/docs/device-apis/alexa-interface.html
299 To compare current supported locales in Home Assistant
300 with Alexa supported locales, run the following script:
301 python -m script.alexa_locales
304 supported_locales = {
324 """Return the Alexa API name of this interface."""
329 """Implements Alexa.EndpointHealth.
331 https://developer.amazon.com/docs/smarthome/state-reporting-for-a-smart-home-skill.html#report-state-when-alexa-requests-it
334 supported_locales = {
353 def __init__(self, hass: HomeAssistant, entity: State) ->
None:
354 """Initialize the entity."""
359 """Return the Alexa API name of this interface."""
360 return "Alexa.EndpointHealth"
363 """Return what properties this entity supports."""
364 return [{
"name":
"connectivity"}]
367 """Return True if properties asynchronously reported."""
371 """Return True if properties can be retrieved."""
375 """Read and return a property."""
376 if name !=
"connectivity":
379 if self.
entityentity.state == STATE_UNAVAILABLE:
380 return {
"value":
"UNREACHABLE"}
381 return {
"value":
"OK"}
385 """Implements Alexa.PowerController.
387 https://developer.amazon.com/docs/device-apis/alexa-powercontroller.html
390 supported_locales = {
410 """Return the Alexa API name of this interface."""
411 return "Alexa.PowerController"
414 """Return what properties this entity supports."""
415 return [{
"name":
"powerState"}]
418 """Return True if properties asynchronously reported."""
422 """Return True if properties can be retrieved."""
426 """Read and return a property."""
427 if name !=
"powerState":
430 if self.
entityentity.domain == climate.DOMAIN:
431 is_on = self.
entityentity.state != climate.HVACMode.OFF
432 elif self.
entityentity.domain == fan.DOMAIN:
433 is_on = self.
entityentity.state == fan.STATE_ON
434 elif self.
entityentity.domain == humidifier.DOMAIN:
435 is_on = self.
entityentity.state == humidifier.STATE_ON
436 elif self.
entityentity.domain == remote.DOMAIN:
437 is_on = self.
entityentity.state
not in (STATE_OFF, STATE_UNKNOWN)
438 elif self.
entityentity.domain == vacuum.DOMAIN:
439 is_on = self.
entityentity.state == vacuum.STATE_CLEANING
440 elif self.
entityentity.domain == timer.DOMAIN:
441 is_on = self.
entityentity.state != STATE_IDLE
442 elif self.
entityentity.domain == water_heater.DOMAIN:
443 is_on = self.
entityentity.state
not in (STATE_OFF, STATE_UNKNOWN)
445 is_on = self.
entityentity.state != STATE_OFF
447 return "ON" if is_on
else "OFF"
451 """Implements Alexa.LockController.
453 https://developer.amazon.com/docs/device-apis/alexa-lockcontroller.html
456 supported_locales = {
476 """Return the Alexa API name of this interface."""
477 return "Alexa.LockController"
480 """Return what properties this entity supports."""
481 return [{
"name":
"lockState"}]
484 """Return True if properties can be retrieved."""
488 """Return True if properties asynchronously reported."""
492 """Read and return a property."""
493 if name !=
"lockState":
497 if self.
entityentity.state
in (LockState.UNLOCKING, LockState.LOCKED):
500 if self.
entityentity.state
in (LockState.LOCKING, LockState.UNLOCKED):
506 """Implements Alexa.SceneController.
508 https://developer.amazon.com/docs/device-apis/alexa-scenecontroller.html
511 supported_locales = {
529 def __init__(self, entity: State, supports_deactivation: bool) ->
None:
530 """Initialize the entity."""
535 """Return True if the Scene controller supports deactivation."""
539 """Return the Alexa API name of this interface."""
540 return "Alexa.SceneController"
544 """Implements Alexa.BrightnessController.
546 https://developer.amazon.com/docs/device-apis/alexa-brightnesscontroller.html
549 supported_locales = {
569 """Return the Alexa API name of this interface."""
570 return "Alexa.BrightnessController"
573 """Return what properties this entity supports."""
574 return [{
"name":
"brightness"}]
577 """Return True if properties asynchronously reported."""
581 """Return True if properties can be retrieved."""
585 """Read and return a property."""
586 if name !=
"brightness":
588 if brightness := self.
entityentity.attributes.get(
"brightness"):
589 return round(brightness / 255.0 * 100)
594 """Implements Alexa.ColorController.
596 https://developer.amazon.com/docs/device-apis/alexa-colorcontroller.html
599 supported_locales = {
618 """Return the Alexa API name of this interface."""
619 return "Alexa.ColorController"
622 """Return what properties this entity supports."""
623 return [{
"name":
"color"}]
626 """Return True if properties asynchronously reported."""
630 """Return True if properties can be retrieved."""
634 """Read and return a property."""
638 hue_saturation: tuple[float, float] |
None
639 if (hue_saturation := self.
entityentity.attributes.get(light.ATTR_HS_COLOR))
is None:
640 hue_saturation = (0, 0)
641 if (brightness := self.
entityentity.attributes.get(light.ATTR_BRIGHTNESS))
is None:
645 "hue": hue_saturation[0],
646 "saturation": hue_saturation[1] / 100.0,
647 "brightness": brightness / 255.0,
652 """Implements Alexa.ColorTemperatureController.
654 https://developer.amazon.com/docs/device-apis/alexa-colortemperaturecontroller.html
657 supported_locales = {
676 """Return the Alexa API name of this interface."""
677 return "Alexa.ColorTemperatureController"
680 """Return what properties this entity supports."""
681 return [{
"name":
"colorTemperatureInKelvin"}]
684 """Return True if properties asynchronously reported."""
688 """Return True if properties can be retrieved."""
692 """Read and return a property."""
693 if name !=
"colorTemperatureInKelvin":
695 if color_temp := self.
entityentity.attributes.get(
"color_temp"):
696 return color_util.color_temperature_mired_to_kelvin(color_temp)
701 """Implements Alexa.Speaker.
703 https://developer.amazon.com/docs/device-apis/alexa-speaker.html
706 supported_locales = {
721 """Return the Alexa API name of this interface."""
722 return "Alexa.Speaker"
725 """Return what properties this entity supports."""
726 properties = [{
"name":
"volume"}]
728 supported = self.
entityentity.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
729 if supported & media_player.MediaPlayerEntityFeature.VOLUME_MUTE:
730 properties.append({
"name":
"muted"})
735 """Return True if properties asynchronously reported."""
739 """Return True if properties can be retrieved."""
743 """Read and return a property."""
745 current_level = self.
entityentity.attributes.get(
746 media_player.ATTR_MEDIA_VOLUME_LEVEL
748 if current_level
is not None:
749 return round(
float(current_level) * 100)
753 self.
entityentity.attributes.get(media_player.ATTR_MEDIA_VOLUME_MUTED)
760 """Implements Alexa.StepSpeaker.
762 https://developer.amazon.com/docs/device-apis/alexa-stepspeaker.html
765 supported_locales = {
778 """Return the Alexa API name of this interface."""
779 return "Alexa.StepSpeaker"
783 """Implements Alexa.PlaybackController.
785 https://developer.amazon.com/docs/device-apis/alexa-playbackcontroller.html
788 supported_locales = {
808 """Return the Alexa API name of this interface."""
809 return "Alexa.PlaybackController"
812 """Return the supportedOperations object.
814 Supported Operations: FastForward, Next, Pause, Play, Previous, Rewind,
817 supported_features = self.
entityentity.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
822 if self.
entityentity.domain == cover.DOMAIN:
823 operations = {cover.CoverEntityFeature.STOP:
"Stop"}
826 media_player.MediaPlayerEntityFeature.NEXT_TRACK:
"Next",
827 media_player.MediaPlayerEntityFeature.PAUSE:
"Pause",
828 media_player.MediaPlayerEntityFeature.PLAY:
"Play",
829 media_player.MediaPlayerEntityFeature.PREVIOUS_TRACK:
"Previous",
830 media_player.MediaPlayerEntityFeature.STOP:
"Stop",
835 for operation, value
in operations.items()
836 if operation & supported_features
841 """Implements Alexa.InputController.
843 https://developer.amazon.com/docs/device-apis/alexa-inputcontroller.html
846 supported_locales = {
866 """Return the Alexa API name of this interface."""
867 return "Alexa.InputController"
869 def inputs(self) -> list[dict[str, str]] | None:
870 """Return the list of valid supported inputs."""
871 source_list: list[Any] = (
872 self.
entityentity.attributes.get(media_player.ATTR_INPUT_SOURCE_LIST)
or []
874 return AlexaInputController.get_valid_inputs(source_list)
878 """Return list of supported inputs."""
879 input_list: list[dict[str, str]] = []
880 for source
in source_list:
881 if not isinstance(source, str):
884 source.lower().replace(
"-",
"").replace(
"_",
"").replace(
" ",
"")
886 if formatted_source
in Inputs.VALID_SOURCE_NAME_MAP:
888 {
"name": Inputs.VALID_SOURCE_NAME_MAP[formatted_source]}
895 """Implements Alexa.TemperatureSensor.
897 https://developer.amazon.com/docs/device-apis/alexa-temperaturesensor.html
900 supported_locales = {
919 def __init__(self, hass: HomeAssistant, entity: State) ->
None:
920 """Initialize the entity."""
925 """Return the Alexa API name of this interface."""
926 return "Alexa.TemperatureSensor"
929 """Return what properties this entity supports."""
930 return [{
"name":
"temperature"}]
933 """Return True if properties asynchronously reported."""
937 """Return True if properties can be retrieved."""
941 """Read and return a property."""
942 if name !=
"temperature":
945 unit: str = self.
entityentity.attributes.get(
946 ATTR_UNIT_OF_MEASUREMENT, self.
hasshass.config.units.temperature_unit
948 temp: str |
None = self.
entityentity.state
949 if self.
entityentity.domain == climate.DOMAIN:
950 unit = self.
hasshass.config.units.temperature_unit
951 temp = self.
entityentity.attributes.get(climate.ATTR_CURRENT_TEMPERATURE)
952 elif self.
entityentity.domain == water_heater.DOMAIN:
953 unit = self.
hasshass.config.units.temperature_unit
954 temp = self.
entityentity.attributes.get(water_heater.ATTR_CURRENT_TEMPERATURE)
956 if temp
is None or temp
in (STATE_UNAVAILABLE, STATE_UNKNOWN):
960 temp_float =
float(temp)
962 _LOGGER.warning(
"Invalid temp value %s for %s", temp, self.
entityentity.entity_id)
971 """Implements Alexa.ContactSensor.
973 The Alexa.ContactSensor interface describes the properties and events used
974 to report the state of an endpoint that detects contact between two
975 surfaces. For example, a contact sensor can report whether a door or window
978 https://developer.amazon.com/docs/device-apis/alexa-contactsensor.html
981 supported_locales = {
999 def __init__(self, hass: HomeAssistant, entity: State) ->
None:
1000 """Initialize the entity."""
1005 """Return the Alexa API name of this interface."""
1006 return "Alexa.ContactSensor"
1009 """Return what properties this entity supports."""
1010 return [{
"name":
"detectionState"}]
1013 """Return True if properties asynchronously reported."""
1017 """Return True if properties can be retrieved."""
1021 """Read and return a property."""
1022 if name !=
"detectionState":
1025 if self.
entityentity.state == STATE_ON:
1027 return "NOT_DETECTED"
1031 """Implements Alexa.MotionSensor.
1033 https://developer.amazon.com/docs/device-apis/alexa-motionsensor.html
1036 supported_locales = {
1054 def __init__(self, hass: HomeAssistant, entity: State) ->
None:
1055 """Initialize the entity."""
1060 """Return the Alexa API name of this interface."""
1061 return "Alexa.MotionSensor"
1064 """Return what properties this entity supports."""
1065 return [{
"name":
"detectionState"}]
1068 """Return True if properties asynchronously reported."""
1072 """Return True if properties can be retrieved."""
1076 """Read and return a property."""
1077 if name !=
"detectionState":
1080 if self.
entityentity.state == STATE_ON:
1082 return "NOT_DETECTED"
1086 """Implements Alexa.ThermostatController.
1088 https://developer.amazon.com/docs/device-apis/alexa-thermostatcontroller.html
1091 supported_locales = {
1110 def __init__(self, hass: HomeAssistant, entity: State) ->
None:
1111 """Initialize the entity."""
1116 """Return the Alexa API name of this interface."""
1117 return "Alexa.ThermostatController"
1120 """Return what properties this entity supports."""
1121 properties = [{
"name":
"thermostatMode"}]
1122 supported = self.
entityentity.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
1123 if self.
entityentity.domain == climate.DOMAIN:
1124 if supported & climate.ClimateEntityFeature.TARGET_TEMPERATURE_RANGE:
1125 properties.append({
"name":
"lowerSetpoint"})
1126 properties.append({
"name":
"upperSetpoint"})
1127 if supported & climate.ClimateEntityFeature.TARGET_TEMPERATURE:
1128 properties.append({
"name":
"targetSetpoint"})
1130 self.
entityentity.domain == water_heater.DOMAIN
1131 and supported & water_heater.WaterHeaterEntityFeature.TARGET_TEMPERATURE
1133 properties.append({
"name":
"targetSetpoint"})
1137 """Return True if properties asynchronously reported."""
1141 """Return True if properties can be retrieved."""
1145 """Read and return a property."""
1146 if self.
entityentity.state == STATE_UNAVAILABLE:
1149 if name ==
"thermostatMode":
1150 if self.
entityentity.domain == water_heater.DOMAIN:
1152 preset = self.
entityentity.attributes.get(climate.ATTR_PRESET_MODE)
1154 mode: dict[str, str] | str |
None
1155 if preset
in API_THERMOSTAT_PRESETS:
1156 mode = API_THERMOSTAT_PRESETS[preset]
1157 elif self.
entityentity.state == STATE_UNKNOWN:
1160 if self.
entityentity.state
not in API_THERMOSTAT_MODES:
1162 "%s (%s) has unsupported state value '%s'",
1163 self.
entityentity.entity_id,
1168 mode = API_THERMOSTAT_MODES[HVACMode(self.
entityentity.state)]
1171 unit = self.
hasshass.config.units.temperature_unit
1172 if name ==
"targetSetpoint":
1173 temp = self.
entityentity.attributes.get(ATTR_TEMPERATURE)
1174 elif name ==
"lowerSetpoint":
1175 temp = self.
entityentity.attributes.get(climate.ATTR_TARGET_TEMP_LOW)
1176 elif name ==
"upperSetpoint":
1177 temp = self.
entityentity.attributes.get(climate.ATTR_TARGET_TEMP_HIGH)
1188 "Invalid temp value %s for %s in %s", temp, name, self.
entityentity.entity_id
1192 return {
"value": temp,
"scale": API_TEMP_UNITS[unit]}
1195 """Return configuration object.
1197 Translates climate HVAC_MODES and PRESETS to supported Alexa
1198 ThermostatMode Values.
1200 ThermostatMode Value must be AUTO, COOL, HEAT, ECO, OFF, or CUSTOM.
1201 Water heater devices do not return thermostat modes.
1203 if self.
entityentity.domain == water_heater.DOMAIN:
1206 hvac_modes = self.
entityentity.attributes.get(climate.ATTR_HVAC_MODES)
or []
1207 supported_modes: list[str] = [
1208 API_THERMOSTAT_MODES[mode]
1209 for mode
in hvac_modes
1210 if mode
in API_THERMOSTAT_MODES
1213 preset_modes = self.
entityentity.attributes.get(climate.ATTR_PRESET_MODES)
1215 for mode
in preset_modes:
1216 thermostat_mode = API_THERMOSTAT_PRESETS.get(mode)
1218 supported_modes.append(thermostat_mode)
1222 configuration: dict[str, Any] = {
"supportsScheduling":
False}
1225 configuration[
"supportedModes"] = supported_modes
1227 return configuration
1231 """Implements Alexa.PowerLevelController.
1233 https://developer.amazon.com/docs/device-apis/alexa-powerlevelcontroller.html
1236 supported_locales = {
1252 """Return the Alexa API name of this interface."""
1253 return "Alexa.PowerLevelController"
1256 """Return what properties this entity supports."""
1257 return [{
"name":
"powerLevel"}]
1260 """Return True if properties asynchronously reported."""
1264 """Return True if properties can be retrieved."""
1268 """Read and return a property."""
1269 if name !=
"powerLevel":
1274 """Implements Alexa.SecurityPanelController.
1276 https://developer.amazon.com/docs/device-apis/alexa-securitypanelcontroller.html
1279 supported_locales = {
1296 def __init__(self, hass: HomeAssistant, entity: State) ->
None:
1297 """Initialize the entity."""
1302 """Return the Alexa API name of this interface."""
1303 return "Alexa.SecurityPanelController"
1306 """Return what properties this entity supports."""
1307 return [{
"name":
"armState"}]
1310 """Return True if properties asynchronously reported."""
1314 """Return True if properties can be retrieved."""
1318 """Read and return a property."""
1319 if name !=
"armState":
1322 arm_state = self.
entityentity.state
1323 if arm_state == AlarmControlPanelState.ARMED_HOME:
1325 if arm_state == AlarmControlPanelState.ARMED_AWAY:
1327 if arm_state == AlarmControlPanelState.ARMED_NIGHT:
1328 return "ARMED_NIGHT"
1329 if arm_state == AlarmControlPanelState.ARMED_CUSTOM_BYPASS:
1334 """Return configuration object with supported authorization types."""
1335 code_format = self.
entityentity.attributes.get(ATTR_CODE_FORMAT)
1336 supported = self.
entityentity.attributes[ATTR_SUPPORTED_FEATURES]
1339 supported_arm_states = [{
"value":
"DISARMED"}]
1340 if supported & AlarmControlPanelEntityFeature.ARM_AWAY:
1341 supported_arm_states.append({
"value":
"ARMED_AWAY"})
1342 if supported & AlarmControlPanelEntityFeature.ARM_HOME:
1343 supported_arm_states.append({
"value":
"ARMED_STAY"})
1344 if supported & AlarmControlPanelEntityFeature.ARM_NIGHT:
1345 supported_arm_states.append({
"value":
"ARMED_NIGHT"})
1347 configuration[
"supportedArmStates"] = supported_arm_states
1349 if code_format == CodeFormat.NUMBER:
1350 configuration[
"supportedAuthorizationTypes"] = [{
"type":
"FOUR_DIGIT_PIN"}]
1352 return configuration
1356 """Implements Alexa.ModeController.
1358 The instance property must be unique across ModeController, RangeController,
1359 ToggleController within the same device.
1361 The instance property should be a concatenated string of device domain period
1362 and single word. e.g. fan.speed & fan.direction.
1364 The instance property must not contain words from other instance property
1365 strings within the same device. e.g. Instance property cover.position &
1366 cover.tilt_position will cause the Alexa.Discovery directive to fail.
1368 An instance property string value may be reused for different devices.
1370 https://developer.amazon.com/docs/device-apis/alexa-modecontroller.html
1373 supported_locales = {
1392 self, entity: State, instance: str, non_controllable: bool =
False
1394 """Initialize the entity."""
1395 AlexaCapability.__init__(self, entity, instance, non_controllable)
1400 """Return the Alexa API name of this interface."""
1401 return "Alexa.ModeController"
1404 """Return what properties this entity supports."""
1405 return [{
"name":
"mode"}]
1408 """Return True if properties asynchronously reported."""
1412 """Return True if properties can be retrieved."""
1416 """Read and return a property."""
1422 mode = self.
entityentity.attributes.get(fan.ATTR_DIRECTION,
None)
1423 if mode
in (fan.DIRECTION_FORWARD, fan.DIRECTION_REVERSE, STATE_UNKNOWN):
1424 return f
"{fan.ATTR_DIRECTION}.{mode}"
1427 if self.
instanceinstanceinstance == f
"{fan.DOMAIN}.{fan.ATTR_PRESET_MODE}":
1428 mode = self.
entityentity.attributes.get(fan.ATTR_PRESET_MODE,
None)
1429 if mode
in self.
entityentity.attributes.get(fan.ATTR_PRESET_MODES,
None):
1430 return f
"{fan.ATTR_PRESET_MODE}.{mode}"
1433 if self.
instanceinstanceinstance == f
"{humidifier.DOMAIN}.{humidifier.ATTR_MODE}":
1434 mode = self.
entityentity.attributes.get(humidifier.ATTR_MODE)
1435 modes: list[str] = (
1436 self.
entityentity.attributes.get(humidifier.ATTR_AVAILABLE_MODES)
or []
1439 return f
"{humidifier.ATTR_MODE}.{mode}"
1442 if self.
instanceinstanceinstance == f
"{remote.DOMAIN}.{remote.ATTR_ACTIVITY}":
1443 activity = self.
entityentity.attributes.get(remote.ATTR_CURRENT_ACTIVITY,
None)
1444 if activity
in self.
entityentity.attributes.get(remote.ATTR_ACTIVITY_LIST, []):
1445 return f
"{remote.ATTR_ACTIVITY}.{activity}"
1448 if self.
instanceinstanceinstance == f
"{water_heater.DOMAIN}.{water_heater.ATTR_OPERATION_MODE}":
1449 operation_mode = self.
entityentity.attributes.get(
1450 water_heater.ATTR_OPERATION_MODE
1452 operation_modes: list[str] = (
1453 self.
entityentity.attributes.get(water_heater.ATTR_OPERATION_LIST)
or []
1455 if operation_mode
in operation_modes:
1456 return f
"{water_heater.ATTR_OPERATION_MODE}.{operation_mode}"
1459 if self.
instanceinstanceinstance == f
"{cover.DOMAIN}.{cover.ATTR_POSITION}":
1461 mode = self.
entityentity.state
1464 cover.STATE_OPENING,
1466 cover.STATE_CLOSING,
1469 return f
"{cover.ATTR_POSITION}.{mode}"
1474 state = self.
entityentity.state
1477 valve.STATE_OPENING,
1479 valve.STATE_CLOSING,
1482 return f
"state.{state}"
1487 """Return configuration with modeResources."""
1488 if isinstance(self.
_resource_resource, AlexaCapabilityResource):
1489 return self.
_resource_resource.serialize_configuration()
1494 """Return capabilityResources object."""
1499 [AlexaGlobalCatalog.SETTING_DIRECTION],
False
1502 f
"{fan.ATTR_DIRECTION}.{fan.DIRECTION_FORWARD}", [fan.DIRECTION_FORWARD]
1505 f
"{fan.ATTR_DIRECTION}.{fan.DIRECTION_REVERSE}", [fan.DIRECTION_REVERSE]
1507 return self.
_resource_resource.serialize_capability_resources()
1510 if self.
instanceinstanceinstance == f
"{fan.DOMAIN}.{fan.ATTR_PRESET_MODE}":
1512 [AlexaGlobalCatalog.SETTING_PRESET],
False
1514 preset_modes = self.
entityentity.attributes.get(fan.ATTR_PRESET_MODES)
or []
1515 for preset_mode
in preset_modes:
1517 f
"{fan.ATTR_PRESET_MODE}.{preset_mode}", [preset_mode]
1521 if len(preset_modes) == 1:
1523 f
"{fan.ATTR_PRESET_MODE}.{PRESET_MODE_NA}", [PRESET_MODE_NA]
1525 return self.
_resource_resource.serialize_capability_resources()
1528 if self.
instanceinstanceinstance == f
"{humidifier.DOMAIN}.{humidifier.ATTR_MODE}":
1530 modes = self.
entityentity.attributes.get(humidifier.ATTR_AVAILABLE_MODES)
or []
1532 self.
_resource_resource.add_mode(f
"{humidifier.ATTR_MODE}.{mode}", [mode])
1537 f
"{humidifier.ATTR_MODE}.{PRESET_MODE_NA}", [PRESET_MODE_NA]
1539 return self.
_resource_resource.serialize_capability_resources()
1542 if self.
instanceinstanceinstance == f
"{water_heater.DOMAIN}.{water_heater.ATTR_OPERATION_MODE}":
1545 self.
entityentity.attributes.get(water_heater.ATTR_OPERATION_LIST)
or []
1547 for operation_mode
in operation_modes:
1549 f
"{water_heater.ATTR_OPERATION_MODE}.{operation_mode}",
1554 if len(operation_modes) == 1:
1556 f
"{water_heater.ATTR_OPERATION_MODE}.{PRESET_MODE_NA}",
1559 return self.
_resource_resource.serialize_capability_resources()
1562 if self.
instanceinstanceinstance == f
"{remote.DOMAIN}.{remote.ATTR_ACTIVITY}":
1566 activities = self.
entityentity.attributes.get(remote.ATTR_ACTIVITY_LIST)
or []
1567 for activity
in activities:
1569 f
"{remote.ATTR_ACTIVITY}.{activity}", [activity]
1573 if len(activities) == 1:
1575 f
"{remote.ATTR_ACTIVITY}.{PRESET_MODE_NA}", [PRESET_MODE_NA]
1577 return self.
_resource_resource.serialize_capability_resources()
1580 if self.
instanceinstanceinstance == f
"{cover.DOMAIN}.{cover.ATTR_POSITION}":
1582 [
"Position", AlexaGlobalCatalog.SETTING_OPENING],
False
1585 f
"{cover.ATTR_POSITION}.{cover.STATE_OPEN}",
1586 [AlexaGlobalCatalog.VALUE_OPEN],
1589 f
"{cover.ATTR_POSITION}.{cover.STATE_CLOSED}",
1590 [AlexaGlobalCatalog.VALUE_CLOSE],
1593 f
"{cover.ATTR_POSITION}.custom",
1594 [
"Custom", AlexaGlobalCatalog.SETTING_PRESET],
1596 return self.
_resource_resource.serialize_capability_resources()
1600 supported_features = self.
entityentity.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
1602 [
"Preset", AlexaGlobalCatalog.SETTING_PRESET],
False
1605 if supported_features & valve.ValveEntityFeature.OPEN:
1607 f
"state.{valve.STATE_OPEN}",
1608 [
"Open", AlexaGlobalCatalog.SETTING_PRESET],
1611 if supported_features & valve.ValveEntityFeature.CLOSE:
1613 f
"state.{valve.STATE_CLOSED}",
1614 [
"Closed", AlexaGlobalCatalog.SETTING_PRESET],
1620 self.
_resource_resource.add_mode(f
"state.{PRESET_MODE_NA}", [PRESET_MODE_NA])
1622 return self.
_resource_resource.serialize_capability_resources()
1627 """Build and return semantics object."""
1628 supported = self.
entityentity.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
1631 if self.
instanceinstanceinstance == f
"{cover.DOMAIN}.{cover.ATTR_POSITION}":
1632 lower_labels = [AlexaSemantics.ACTION_LOWER]
1633 raise_labels = [AlexaSemantics.ACTION_RAISE]
1637 if not supported & cover.CoverEntityFeature.SET_TILT_POSITION:
1638 lower_labels.append(AlexaSemantics.ACTION_CLOSE)
1639 raise_labels.append(AlexaSemantics.ACTION_OPEN)
1640 self.
_semantics_semantics.add_states_to_value(
1641 [AlexaSemantics.STATES_CLOSED],
1642 f
"{cover.ATTR_POSITION}.{cover.STATE_CLOSED}",
1644 self.
_semantics_semantics.add_states_to_value(
1645 [AlexaSemantics.STATES_OPEN],
1646 f
"{cover.ATTR_POSITION}.{cover.STATE_OPEN}",
1649 self.
_semantics_semantics.add_action_to_directive(
1652 {
"mode": f
"{cover.ATTR_POSITION}.{cover.STATE_CLOSED}"},
1654 self.
_semantics_semantics.add_action_to_directive(
1657 {
"mode": f
"{cover.ATTR_POSITION}.{cover.STATE_OPEN}"},
1660 return self.
_semantics_semantics.serialize_semantics()
1664 close_labels = [AlexaSemantics.ACTION_CLOSE]
1665 open_labels = [AlexaSemantics.ACTION_OPEN]
1668 self.
_semantics_semantics.add_states_to_value(
1669 [AlexaSemantics.STATES_CLOSED],
1670 f
"state.{valve.STATE_CLOSED}",
1672 self.
_semantics_semantics.add_states_to_value(
1673 [AlexaSemantics.STATES_OPEN],
1674 f
"state.{valve.STATE_OPEN}",
1677 self.
_semantics_semantics.add_action_to_directive(
1680 {
"mode": f
"state.{valve.STATE_CLOSED}"},
1682 self.
_semantics_semantics.add_action_to_directive(
1685 {
"mode": f
"state.{valve.STATE_OPEN}"},
1688 return self.
_semantics_semantics.serialize_semantics()
1694 """Implements Alexa.RangeController.
1696 The instance property must be unique across ModeController, RangeController,
1697 ToggleController within the same device.
1699 The instance property should be a concatenated string of device domain period
1700 and single word. e.g. fan.speed & fan.direction.
1702 The instance property must not contain words from other instance property
1703 strings within the same device. e.g. Instance property cover.position &
1704 cover.tilt_position will cause the Alexa.Discovery directive to fail.
1706 An instance property string value may be reused for different devices.
1708 https://developer.amazon.com/docs/device-apis/alexa-rangecontroller.html
1711 supported_locales = {
1730 self, entity: State, instance: str |
None, non_controllable: bool =
False
1732 """Initialize the entity."""
1733 AlexaCapability.__init__(self, entity, instance, non_controllable)
1738 """Return the Alexa API name of this interface."""
1739 return "Alexa.RangeController"
1742 """Return what properties this entity supports."""
1743 return [{
"name":
"rangeValue"}]
1746 """Return True if properties asynchronously reported."""
1750 """Return True if properties can be retrieved."""
1754 """Read and return a property."""
1755 if name !=
"rangeValue":
1761 if self.
entityentity.state
in (STATE_UNAVAILABLE, STATE_UNKNOWN,
None):
1766 return self.
entityentity.attributes.get(cover.ATTR_CURRENT_POSITION)
1770 return self.
entityentity.attributes.get(cover.ATTR_CURRENT_TILT_POSITION)
1774 supported = self.
entityentity.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
1775 if supported
and fan.FanEntityFeature.SET_SPEED:
1776 return self.
entityentity.attributes.get(fan.ATTR_PERCENTAGE)
1777 return 100
if self.
entityentity.state == fan.STATE_ON
else 0
1780 if self.
instanceinstanceinstance == f
"{humidifier.DOMAIN}.{humidifier.ATTR_HUMIDITY}":
1783 return self.
entityentity.attributes.get(humidifier.ATTR_HUMIDITY, 0)
1786 if self.
instanceinstanceinstance == f
"{input_number.DOMAIN}.{input_number.ATTR_VALUE}":
1790 if self.
instanceinstanceinstance == f
"{number.DOMAIN}.{number.ATTR_VALUE}":
1794 if self.
instanceinstanceinstance == f
"{vacuum.DOMAIN}.{vacuum.ATTR_FAN_SPEED}":
1795 speed_list = self.
entityentity.attributes.get(vacuum.ATTR_FAN_SPEED_LIST)
1796 speed = self.
entityentity.attributes.get(vacuum.ATTR_FAN_SPEED)
1797 if speed_list
is not None and speed
is not None:
1798 return next((i
for i, v
in enumerate(speed_list)
if v == speed),
None)
1801 if self.
instanceinstanceinstance == f
"{valve.DOMAIN}.{valve.ATTR_POSITION}":
1802 return self.
entityentity.attributes.get(valve.ATTR_CURRENT_POSITION)
1807 """Return configuration with presetResources."""
1808 if isinstance(self.
_resource_resource, AlexaCapabilityResource):
1809 return self.
_resource_resource.serialize_configuration()
1814 """Return capabilityResources object."""
1818 percentage_step = self.
entityentity.attributes.get(fan.ATTR_PERCENTAGE_STEP)
1820 labels=[
"Percentage", AlexaGlobalCatalog.SETTING_FAN_SPEED],
1825 precision=1
if percentage_step
else 100,
1826 unit=AlexaGlobalCatalog.UNIT_PERCENT,
1828 return self.
_resource_resource.serialize_capability_resources()
1831 if self.
instanceinstanceinstance == f
"{humidifier.DOMAIN}.{humidifier.ATTR_HUMIDITY}":
1833 labels=[
"Humidity",
"Percentage",
"Target humidity"],
1834 min_value=self.
entityentity.attributes.get(humidifier.ATTR_MIN_HUMIDITY, 10),
1835 max_value=self.
entityentity.attributes.get(humidifier.ATTR_MAX_HUMIDITY, 90),
1837 unit=AlexaGlobalCatalog.UNIT_PERCENT,
1839 return self.
_resource_resource.serialize_capability_resources()
1842 if self.
instanceinstanceinstance == f
"{cover.DOMAIN}.{cover.ATTR_POSITION}":
1844 [
"Position", AlexaGlobalCatalog.SETTING_OPENING],
1848 unit=AlexaGlobalCatalog.UNIT_PERCENT,
1850 return self.
_resource_resource.serialize_capability_resources()
1855 [
"Tilt",
"Angle", AlexaGlobalCatalog.SETTING_DIRECTION],
1859 unit=AlexaGlobalCatalog.UNIT_PERCENT,
1861 return self.
_resource_resource.serialize_capability_resources()
1864 if self.
instanceinstanceinstance == f
"{input_number.DOMAIN}.{input_number.ATTR_VALUE}":
1865 min_value =
float(self.
entityentity.attributes[input_number.ATTR_MIN])
1866 max_value =
float(self.
entityentity.attributes[input_number.ATTR_MAX])
1867 precision =
float(self.
entityentity.attributes.get(input_number.ATTR_STEP, 1))
1868 unit = self.
entityentity.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
1872 min_value=min_value,
1873 max_value=max_value,
1874 precision=precision,
1878 value=min_value, labels=[AlexaGlobalCatalog.VALUE_MINIMUM]
1881 value=max_value, labels=[AlexaGlobalCatalog.VALUE_MAXIMUM]
1883 return self.
_resource_resource.serialize_capability_resources()
1886 if self.
instanceinstanceinstance == f
"{number.DOMAIN}.{number.ATTR_VALUE}":
1887 min_value =
float(self.
entityentity.attributes[number.ATTR_MIN])
1888 max_value =
float(self.
entityentity.attributes[number.ATTR_MAX])
1889 precision =
float(self.
entityentity.attributes.get(number.ATTR_STEP, 1))
1890 unit = self.
entityentity.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
1894 min_value=min_value,
1895 max_value=max_value,
1896 precision=precision,
1900 value=min_value, labels=[AlexaGlobalCatalog.VALUE_MINIMUM]
1903 value=max_value, labels=[AlexaGlobalCatalog.VALUE_MAXIMUM]
1905 return self.
_resource_resource.serialize_capability_resources()
1908 if self.
instanceinstanceinstance == f
"{vacuum.DOMAIN}.{vacuum.ATTR_FAN_SPEED}":
1909 speed_list = self.
entityentity.attributes[vacuum.ATTR_FAN_SPEED_LIST]
1910 max_value = len(speed_list) - 1
1912 labels=[AlexaGlobalCatalog.SETTING_FAN_SPEED],
1914 max_value=max_value,
1917 for index, speed
in enumerate(speed_list):
1918 labels = [speed.replace(
"_",
" ")]
1920 labels.append(AlexaGlobalCatalog.VALUE_MINIMUM)
1921 if index == max_value:
1922 labels.append(AlexaGlobalCatalog.VALUE_MAXIMUM)
1923 self.
_resource_resource.add_preset(value=index, labels=labels)
1925 return self.
_resource_resource.serialize_capability_resources()
1928 if self.
instanceinstanceinstance == f
"{valve.DOMAIN}.{valve.ATTR_POSITION}":
1930 [
"Opening", AlexaGlobalCatalog.SETTING_OPENING],
1934 unit=AlexaGlobalCatalog.UNIT_PERCENT,
1936 return self.
_resource_resource.serialize_capability_resources()
1941 """Build and return semantics object."""
1942 supported = self.
entityentity.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
1945 if self.
instanceinstanceinstance == f
"{cover.DOMAIN}.{cover.ATTR_POSITION}":
1946 lower_labels = [AlexaSemantics.ACTION_LOWER]
1947 raise_labels = [AlexaSemantics.ACTION_RAISE]
1951 if not supported & cover.CoverEntityFeature.SET_TILT_POSITION:
1952 lower_labels.append(AlexaSemantics.ACTION_CLOSE)
1953 raise_labels.append(AlexaSemantics.ACTION_OPEN)
1954 self.
_semantics_semantics.add_states_to_value(
1955 [AlexaSemantics.STATES_CLOSED], value=0
1957 self.
_semantics_semantics.add_states_to_range(
1958 [AlexaSemantics.STATES_OPEN], min_value=1, max_value=100
1961 self.
_semantics_semantics.add_action_to_directive(
1962 lower_labels,
"SetRangeValue", {
"rangeValue": 0}
1964 self.
_semantics_semantics.add_action_to_directive(
1965 raise_labels,
"SetRangeValue", {
"rangeValue": 100}
1967 return self.
_semantics_semantics.serialize_semantics()
1972 self.
_semantics_semantics.add_action_to_directive(
1973 [AlexaSemantics.ACTION_CLOSE],
"SetRangeValue", {
"rangeValue": 0}
1975 self.
_semantics_semantics.add_action_to_directive(
1976 [AlexaSemantics.ACTION_OPEN],
"SetRangeValue", {
"rangeValue": 100}
1978 self.
_semantics_semantics.add_states_to_value([AlexaSemantics.STATES_CLOSED], value=0)
1979 self.
_semantics_semantics.add_states_to_range(
1980 [AlexaSemantics.STATES_OPEN], min_value=1, max_value=100
1982 return self.
_semantics_semantics.serialize_semantics()
1986 lower_labels = [AlexaSemantics.ACTION_LOWER]
1987 raise_labels = [AlexaSemantics.ACTION_RAISE]
1990 self.
_semantics_semantics.add_action_to_directive(
1991 lower_labels,
"SetRangeValue", {
"rangeValue": 0}
1993 self.
_semantics_semantics.add_action_to_directive(
1994 raise_labels,
"SetRangeValue", {
"rangeValue": 100}
1996 return self.
_semantics_semantics.serialize_semantics()
1999 if self.
instanceinstanceinstance == f
"{humidifier.DOMAIN}.{humidifier.ATTR_HUMIDITY}":
2000 lower_labels = [AlexaSemantics.ACTION_LOWER]
2001 raise_labels = [AlexaSemantics.ACTION_RAISE]
2003 min_value = self.
entityentity.attributes.get(humidifier.ATTR_MIN_HUMIDITY, 10)
2004 max_value = self.
entityentity.attributes.get(humidifier.ATTR_MAX_HUMIDITY, 90)
2006 self.
_semantics_semantics.add_action_to_directive(
2007 lower_labels,
"SetRangeValue", {
"rangeValue": min_value}
2009 self.
_semantics_semantics.add_action_to_directive(
2010 raise_labels,
"SetRangeValue", {
"rangeValue": max_value}
2012 return self.
_semantics_semantics.serialize_semantics()
2015 if self.
instanceinstanceinstance == f
"{valve.DOMAIN}.{valve.ATTR_POSITION}":
2016 close_labels = [AlexaSemantics.ACTION_CLOSE]
2017 open_labels = [AlexaSemantics.ACTION_OPEN]
2020 self.
_semantics_semantics.add_states_to_value([AlexaSemantics.STATES_CLOSED], value=0)
2021 self.
_semantics_semantics.add_states_to_range(
2022 [AlexaSemantics.STATES_OPEN], min_value=1, max_value=100
2025 self.
_semantics_semantics.add_action_to_directive(
2026 close_labels,
"SetRangeValue", {
"rangeValue": 0}
2028 self.
_semantics_semantics.add_action_to_directive(
2029 open_labels,
"SetRangeValue", {
"rangeValue": 100}
2031 return self.
_semantics_semantics.serialize_semantics()
2037 """Implements Alexa.ToggleController.
2039 The instance property must be unique across ModeController, RangeController,
2040 ToggleController within the same device.
2042 The instance property should be a concatenated string of device domain period
2043 and single word. e.g. fan.speed & fan.direction.
2045 The instance property must not contain words from other instance property
2046 strings within the same device. e.g. Instance property cover.position
2047 & cover.tilt_position will cause the Alexa.Discovery directive to fail.
2049 An instance property string value may be reused for different devices.
2051 https://developer.amazon.com/docs/device-apis/alexa-togglecontroller.html
2054 supported_locales = {
2073 self, entity: State, instance: str, non_controllable: bool =
False
2075 """Initialize the entity."""
2076 AlexaCapability.__init__(self, entity, instance, non_controllable)
2081 """Return the Alexa API name of this interface."""
2082 return "Alexa.ToggleController"
2085 """Return what properties this entity supports."""
2086 return [{
"name":
"toggleState"}]
2089 """Return True if properties asynchronously reported."""
2093 """Return True if properties can be retrieved."""
2097 """Read and return a property."""
2098 if name !=
"toggleState":
2103 is_on = bool(self.
entityentity.attributes.get(fan.ATTR_OSCILLATING))
2104 return "ON" if is_on
else "OFF"
2113 """Return capabilityResources object."""
2116 if self.
instanceinstanceinstance == f
"{fan.DOMAIN}.{fan.ATTR_OSCILLATING}":
2118 [AlexaGlobalCatalog.SETTING_OSCILLATE,
"Rotate",
"Rotation"]
2120 return self.
_resource_resource.serialize_capability_resources()
2124 return self.
_resource_resource.serialize_capability_resources()
2130 """Implements Alexa.ChannelController.
2132 https://developer.amazon.com/docs/device-apis/alexa-channelcontroller.html
2135 supported_locales = {
2155 """Return the Alexa API name of this interface."""
2156 return "Alexa.ChannelController"
2160 """Implements Alexa.DoorbellEventSource.
2162 https://developer.amazon.com/docs/device-apis/alexa-doorbelleventsource.html
2165 supported_locales = {
2185 """Return the Alexa API name of this interface."""
2186 return "Alexa.DoorbellEventSource"
2189 """Return True for proactively reported capability."""
2194 """Implements Alexa.PlaybackStateReporter.
2196 https://developer.amazon.com/docs/device-apis/alexa-playbackstatereporter.html
2199 supported_locales = {
2219 """Return the Alexa API name of this interface."""
2220 return "Alexa.PlaybackStateReporter"
2223 """Return what properties this entity supports."""
2224 return [{
"name":
"playbackState"}]
2227 """Return True if properties asynchronously reported."""
2231 """Return True if properties can be retrieved."""
2235 """Read and return a property."""
2236 if name !=
"playbackState":
2239 playback_state = self.
entityentity.state
2240 if playback_state == STATE_PLAYING:
2241 return {
"state":
"PLAYING"}
2242 if playback_state == STATE_PAUSED:
2243 return {
"state":
"PAUSED"}
2245 return {
"state":
"STOPPED"}
2249 """Implements Alexa.SeekController.
2251 https://developer.amazon.com/docs/device-apis/alexa-seekcontroller.html
2254 supported_locales = {
2274 """Return the Alexa API name of this interface."""
2275 return "Alexa.SeekController"
2279 """Implements Alexa.EventDetectionSensor.
2281 https://developer.amazon.com/docs/device-apis/alexa-eventdetectionsensor.html
2284 supported_locales = {
"en-US"}
2286 def __init__(self, hass: HomeAssistant, entity: State) ->
None:
2287 """Initialize the entity."""
2292 """Return the Alexa API name of this interface."""
2293 return "Alexa.EventDetectionSensor"
2296 """Return what properties this entity supports."""
2297 return [{
"name":
"humanPresenceDetectionState"}]
2300 """Return True if properties asynchronously reported."""
2304 """Read and return a property."""
2305 if name !=
"humanPresenceDetectionState":
2308 human_presence =
"NOT_DETECTED"
2309 state = self.
entityentity.state
2314 if state
in (STATE_UNAVAILABLE, STATE_UNKNOWN,
None):
2317 if self.
entityentity.domain == image_processing.DOMAIN:
2319 human_presence =
"DETECTED"
2320 elif state == STATE_ON
or self.
entityentity.domain
in [
2321 input_button.DOMAIN,
2324 human_presence =
"DETECTED"
2326 return {
"value": human_presence}
2329 """Return supported detection types."""
2331 "detectionMethods": [
"AUDIO",
"VIDEO"],
2334 "featureAvailability":
"ENABLED",
2335 "supportsNotDetected": self.
entityentity.domain
2336 not in [input_button.DOMAIN, button.DOMAIN],
2343 """Implements Alexa.EqualizerController.
2345 https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-equalizercontroller.html
2348 supported_locales = {
2366 VALID_SOUND_MODES = {
2375 """Return the Alexa API name of this interface."""
2376 return "Alexa.EqualizerController"
2379 """Return what properties this entity supports.
2381 Either bands, mode or both can be specified. Only mode is supported
2384 return [{
"name":
"mode"}]
2387 """Return True if properties can be retrieved."""
2391 """Read and return a property."""
2395 sound_mode = self.
entityentity.attributes.get(media_player.ATTR_SOUND_MODE)
2396 if sound_mode
and sound_mode.upper()
in self.
VALID_SOUND_MODESVALID_SOUND_MODES:
2397 return sound_mode.upper()
2402 """Return the sound modes supported in the configurations object."""
2403 configurations =
None
2405 self.
entityentity.attributes.get(media_player.ATTR_SOUND_MODE_LIST)
or []
2407 if supported_sound_modes:
2408 configurations = {
"modes": {
"supported": supported_sound_modes}}
2410 return configurations
2414 """Return list of supported inputs."""
2415 input_list: list[dict[str, str]] = []
2416 for sound_mode
in sound_mode_list:
2417 sound_mode = sound_mode.upper()
2420 input_list.append({
"name": sound_mode})
2426 """Implements Alexa.TimeHoldController.
2428 https://developer.amazon.com/docs/device-apis/alexa-timeholdcontroller.html
2431 supported_locales = {
"en-US"}
2433 def __init__(self, entity: State, allow_remote_resume: bool =
False) ->
None:
2434 """Initialize the entity."""
2439 """Return the Alexa API name of this interface."""
2440 return "Alexa.TimeHoldController"
2443 """Return configuration object.
2445 Set allowRemoteResume to True if Alexa can restart the operation on the device.
2446 When false, Alexa does not send the Resume directive.
2452 """Implements Alexa.CameraStreamController.
2454 https://developer.amazon.com/docs/device-apis/alexa-camerastreamcontroller.html
2457 supported_locales = {
2477 """Return the Alexa API name of this interface."""
2478 return "Alexa.CameraStreamController"
2481 """Return cameraStreamConfigurations object."""
2484 "protocols": [
"HLS"],
2485 "resolutions": [{
"width": 1280,
"height": 720}],
2486 "authorizationTypes": [
"NONE"],
2487 "videoCodecs": [
"H264"],
2488 "audioCodecs": [
"AAC"],
bool properties_retrievable(self)
bool properties_proactively_reported(self)
list[dict[str, str]] properties_supported(self)
Any get_property(self, str name)
list[dict[str, Any]]|None camera_stream_configurations(self)
dict[str, Any] serialize_discovery(self)
bool|None capability_proactively_reported(self)
list[dict] properties_supported(self)
Generator[dict[str, Any]] serialize_properties(self)
_non_controllable_properties
dict[str, Any]|None configurations(self)
bool|None supports_deactivation(self)
dict[str, list[dict[str, Any]]] capability_resources(self)
bool properties_retrievable(self)
dict[str, Any] get_property(self, str name)
dict[str, Any]|None semantics(self)
bool|None properties_non_controllable(self)
bool properties_proactively_reported(self)
list[str] supported_operations(self)
None __init__(self, State entity, str|None instance=None, bool|None non_controllable_properties=None)
list[dict[str, Any]]|None camera_stream_configurations(self)
list[dict[str, str]]|None inputs(self)
dict[str, Any]|None configuration(self)
Any get_property(self, str name)
list[dict[str, str]] properties_supported(self)
bool properties_retrievable(self)
bool properties_proactively_reported(self)
list[dict[str, str]] properties_supported(self)
bool properties_retrievable(self)
bool properties_proactively_reported(self)
Any get_property(self, str name)
bool capability_proactively_reported(self)
None __init__(self, HomeAssistant hass, State entity)
bool properties_proactively_reported(self)
Any get_property(self, str name)
bool properties_retrievable(self)
list[dict[str, str]] properties_supported(self)
list[dict[str, str]] get_valid_inputs(cls, list[str] sound_mode_list)
dictionary VALID_SOUND_MODES
Any get_property(self, str name)
list[dict[str, str]] properties_supported(self)
bool properties_retrievable(self)
dict[str, Any]|None configurations(self)
bool properties_proactively_reported(self)
dict[str, Any]|None configuration(self)
None __init__(self, HomeAssistant hass, State entity)
list[dict[str, str]] properties_supported(self)
Any get_property(self, str name)
list[dict[str, str]] properties_supported(self)
bool properties_retrievable(self)
Any get_property(self, str name)
bool properties_proactively_reported(self)
Any get_property(self, str name)
dict[str, list[dict[str, Any]]] capability_resources(self)
None __init__(self, State entity, str instance, bool non_controllable=False)
dict[str, Any]|None semantics(self)
bool properties_retrievable(self)
list[dict[str, str]] properties_supported(self)
dict[str, Any]|None configuration(self)
bool properties_proactively_reported(self)
bool properties_proactively_reported(self)
list[dict[str, str]] properties_supported(self)
bool properties_retrievable(self)
None __init__(self, HomeAssistant hass, State entity)
Any get_property(self, str name)
list[str] supported_operations(self)
Any get_property(self, str name)
bool properties_proactively_reported(self)
bool properties_retrievable(self)
list[dict[str, str]] properties_supported(self)
list[dict[str, str]] properties_supported(self)
bool properties_retrievable(self)
bool properties_proactively_reported(self)
Any get_property(self, str name)
bool properties_proactively_reported(self)
bool properties_retrievable(self)
list[dict[str, str]] properties_supported(self)
Any get_property(self, str name)
dict[str, Any]|None semantics(self)
dict[str, Any]|None configuration(self)
bool properties_retrievable(self)
Any get_property(self, str name)
dict[str, list[dict[str, Any]]] capability_resources(self)
bool properties_proactively_reported(self)
list[dict[str, str]] properties_supported(self)
None __init__(self, State entity, str|None instance, bool non_controllable=False)
bool|None supports_deactivation(self)
None __init__(self, State entity, bool supports_deactivation)
bool properties_proactively_reported(self)
dict[str, Any]|None configuration(self)
list[dict[str, str]] properties_supported(self)
Any get_property(self, str name)
bool properties_retrievable(self)
None __init__(self, HomeAssistant hass, State entity)
Any get_property(self, str name)
bool properties_proactively_reported(self)
bool properties_retrievable(self)
list[dict[str, str]] properties_supported(self)
bool properties_proactively_reported(self)
Any get_property(self, str name)
list[dict[str, str]] properties_supported(self)
bool properties_retrievable(self)
None __init__(self, HomeAssistant hass, State entity)
None __init__(self, HomeAssistant hass, State entity)
bool properties_proactively_reported(self)
dict[str, Any]|None configuration(self)
list[dict[str, str]] properties_supported(self)
bool properties_retrievable(self)
Any get_property(self, str name)
None __init__(self, State entity, bool allow_remote_resume=False)
dict[str, Any]|None configuration(self)
list[dict[str, str]] properties_supported(self)
None __init__(self, State entity, str instance, bool non_controllable=False)
bool properties_proactively_reported(self)
bool properties_retrievable(self)
Any get_property(self, str name)
dict[str, list[dict[str, Any]]] capability_resources(self)
str get_resource_by_unit_of_measurement(State entity)