Home Assistant Unofficial Reference 2024.12.1
const.py
Go to the documentation of this file.
1 """Constants for the Alexa integration."""
2 
3 from collections import OrderedDict
4 
5 from homeassistant.components import climate
6 from homeassistant.const import UnitOfTemperature
7 
8 DOMAIN = "alexa"
9 EVENT_ALEXA_SMART_HOME = "alexa_smart_home"
10 
11 # Flash briefing constants
12 CONF_UID = "uid"
13 CONF_TITLE = "title"
14 CONF_AUDIO = "audio"
15 CONF_TEXT = "text"
16 CONF_DISPLAY_URL = "display_url"
17 
18 CONF_FILTER = "filter"
19 CONF_ENTITY_CONFIG = "entity_config"
20 CONF_ENDPOINT = "endpoint"
21 CONF_LOCALE = "locale"
22 
23 ATTR_UID = "uid"
24 ATTR_UPDATE_DATE = "updateDate"
25 ATTR_TITLE_TEXT = "titleText"
26 ATTR_STREAM_URL = "streamUrl"
27 ATTR_MAIN_TEXT = "mainText"
28 ATTR_REDIRECTION_URL = "redirectionURL"
29 
30 SYN_RESOLUTION_MATCH = "ER_SUCCESS_MATCH"
31 
32 # Alexa requires timestamps to be formatted according to ISO 8601, YYYY-MM-DDThh:mm:ssZ
33 # https://developer.amazon.com/es-ES/docs/alexa/device-apis/alexa-scenecontroller.html#activate-response-event
34 DATE_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
35 
36 API_DIRECTIVE = "directive"
37 API_ENDPOINT = "endpoint"
38 API_EVENT = "event"
39 API_CONTEXT = "context"
40 API_HEADER = "header"
41 API_PAYLOAD = "payload"
42 API_SCOPE = "scope"
43 API_CHANGE = "change"
44 API_PASSWORD = "password"
45 
46 CONF_DISPLAY_CATEGORIES = "display_categories"
47 CONF_SUPPORTED_LOCALES = (
48  "de-DE",
49  "en-AU",
50  "en-CA",
51  "en-GB",
52  "en-IN",
53  "en-US",
54  "es-ES",
55  "es-MX",
56  "es-US",
57  "fr-CA",
58  "fr-FR",
59  "hi-IN",
60  "it-IT",
61  "ja-JP",
62  "pt-BR",
63 )
64 
65 API_TEMP_UNITS = {
66  UnitOfTemperature.FAHRENHEIT: "FAHRENHEIT",
67  UnitOfTemperature.CELSIUS: "CELSIUS",
68 }
69 
70 # Needs to be ordered dict for `async_api_set_thermostat_mode` which does a
71 # reverse mapping of this dict and we want to map the first occurrence of OFF
72 # back to HA state.
73 API_THERMOSTAT_MODES: OrderedDict[str, str] = OrderedDict(
74  [
75  (climate.HVACMode.HEAT, "HEAT"),
76  (climate.HVACMode.COOL, "COOL"),
77  (climate.HVACMode.HEAT_COOL, "AUTO"),
78  (climate.HVACMode.AUTO, "AUTO"),
79  (climate.HVACMode.OFF, "OFF"),
80  (climate.HVACMode.FAN_ONLY, "CUSTOM"),
81  (climate.HVACMode.DRY, "CUSTOM"),
82  ]
83 )
84 API_THERMOSTAT_MODES_CUSTOM = {
85  climate.HVACMode.DRY: "DEHUMIDIFY",
86  climate.HVACMode.FAN_ONLY: "FAN",
87 }
88 API_THERMOSTAT_PRESETS = {climate.PRESET_ECO: "ECO"}
89 
90 # AlexaModeController does not like a single mode for the fan preset or humidifier mode,
91 # we add PRESET_MODE_NA if a fan / humidifier / remote has only one preset_mode
92 PRESET_MODE_NA = "-"
93 
94 STORAGE_ACCESS_TOKEN = "access_token"
95 STORAGE_REFRESH_TOKEN = "refresh_token"
96 
97 
98 class Cause:
99  """Possible causes for property changes.
100 
101  https://developer.amazon.com/docs/smarthome/state-reporting-for-a-smart-home-skill.html#cause-object
102  """
103 
104  # Indicates that the event was caused by a customer interaction with an
105  # application. For example, a customer switches on a light, or locks a door
106  # using the Alexa app or an app provided by a device vendor.
107  APP_INTERACTION = "APP_INTERACTION"
108 
109  # Indicates that the event was caused by a physical interaction with an
110  # endpoint. For example manually switching on a light or manually locking a
111  # door lock
112  PHYSICAL_INTERACTION = "PHYSICAL_INTERACTION"
113 
114  # Indicates that the event was caused by the periodic poll of an appliance,
115  # which found a change in value. For example, you might poll a temperature
116  # sensor every hour, and send the updated temperature to Alexa.
117  PERIODIC_POLL = "PERIODIC_POLL"
118 
119  # Indicates that the event was caused by the application of a device rule.
120  # For example, a customer configures a rule to switch on a light if a
121  # motion sensor detects motion. In this case, Alexa receives an event from
122  # the motion sensor, and another event from the light to indicate that its
123  # state change was caused by the rule.
124  RULE_TRIGGER = "RULE_TRIGGER"
125 
126  # Indicates that the event was caused by a voice interaction with Alexa.
127  # For example a user speaking to their Echo device.
128  VOICE_INTERACTION = "VOICE_INTERACTION"
129 
130 
131 class Inputs:
132  """Valid names for the InputController.
133 
134  https://developer.amazon.com/docs/device-apis/alexa-property-schemas.html#input
135  """
136 
137  VALID_SOURCE_NAME_MAP = {
138  "antenna": "TUNER",
139  "antennatv": "TUNER",
140  "aux": "AUX 1",
141  "aux1": "AUX 1",
142  "aux2": "AUX 2",
143  "aux3": "AUX 3",
144  "aux4": "AUX 4",
145  "aux5": "AUX 5",
146  "aux6": "AUX 6",
147  "aux7": "AUX 7",
148  "bluray": "BLURAY",
149  "blurayplayer": "BLURAY",
150  "cable": "CABLE",
151  "cd": "CD",
152  "coax": "COAX 1",
153  "coax1": "COAX 1",
154  "coax2": "COAX 2",
155  "composite": "COMPOSITE 1",
156  "composite1": "COMPOSITE 1",
157  "dvd": "DVD",
158  "game": "GAME",
159  "gameconsole": "GAME",
160  "hdradio": "HD RADIO",
161  "hdmi": "HDMI 1",
162  "hdmi1": "HDMI 1",
163  "hdmi2": "HDMI 2",
164  "hdmi3": "HDMI 3",
165  "hdmi4": "HDMI 4",
166  "hdmi5": "HDMI 5",
167  "hdmi6": "HDMI 6",
168  "hdmi7": "HDMI 7",
169  "hdmi8": "HDMI 8",
170  "hdmi9": "HDMI 9",
171  "hdmi10": "HDMI 10",
172  "hdmiarc": "HDMI ARC",
173  "input": "INPUT 1",
174  "input1": "INPUT 1",
175  "input2": "INPUT 2",
176  "input3": "INPUT 3",
177  "input4": "INPUT 4",
178  "input5": "INPUT 5",
179  "input6": "INPUT 6",
180  "input7": "INPUT 7",
181  "input8": "INPUT 8",
182  "input9": "INPUT 9",
183  "input10": "INPUT 10",
184  "ipod": "IPOD",
185  "line": "LINE 1",
186  "line1": "LINE 1",
187  "line2": "LINE 2",
188  "line3": "LINE 3",
189  "line4": "LINE 4",
190  "line5": "LINE 5",
191  "line6": "LINE 6",
192  "line7": "LINE 7",
193  "mediaplayer": "MEDIA PLAYER",
194  "optical": "OPTICAL 1",
195  "optical1": "OPTICAL 1",
196  "optical2": "OPTICAL 2",
197  "phono": "PHONO",
198  "playstation": "PLAYSTATION",
199  "playstation3": "PLAYSTATION 3",
200  "playstation4": "PLAYSTATION 4",
201  "rokumediaplayer": "MEDIA PLAYER",
202  "satellite": "SATELLITE",
203  "satellitetv": "SATELLITE",
204  "smartcast": "SMARTCAST",
205  "tuner": "TUNER",
206  "tv": "TV",
207  "usbdac": "USB DAC",
208  "video": "VIDEO 1",
209  "video1": "VIDEO 1",
210  "video2": "VIDEO 2",
211  "video3": "VIDEO 3",
212  "xbox": "XBOX",
213  }
214 
215  VALID_SOUND_MODE_MAP = {
216  "movie": "MOVIE",
217  "music": "MUSIC",
218  "night": "NIGHT",
219  "sport": "SPORT",
220  "tv": "TV",
221  }