1 """Support for Alexa skill service end point."""
3 from __future__
import annotations
7 import voluptuous
as vol
20 from .
import flash_briefings, intent, smart_home
23 CONF_DISPLAY_CATEGORIES,
29 CONF_SUPPORTED_LOCALES,
36 CONF_FLASH_BRIEFINGS =
"flash_briefings"
37 CONF_SMART_HOME =
"smart_home"
38 DEFAULT_LOCALE =
"en-US"
43 "https://api.amazonalexa.com/v3/events",
44 "https://api.eu.amazonalexa.com/v3/events",
45 "https://api.fe.amazonalexa.com/v3/events",
49 ALEXA_ENTITY_SCHEMA = vol.Schema(
51 vol.Optional(CONF_DESCRIPTION): cv.string,
52 vol.Optional(CONF_DISPLAY_CATEGORIES): cv.string,
53 vol.Optional(CONF_NAME): cv.string,
57 SMART_HOME_SCHEMA = vol.Schema(
59 vol.Optional(CONF_ENDPOINT): vol.All(vol.Lower, vol.In(VALID_ENDPOINTS)),
60 vol.Optional(CONF_CLIENT_ID): cv.string,
61 vol.Optional(CONF_CLIENT_SECRET): cv.string,
62 vol.Optional(CONF_LOCALE, default=DEFAULT_LOCALE): vol.In(
63 CONF_SUPPORTED_LOCALES
65 vol.Optional(CONF_FILTER, default={}): entityfilter.FILTER_SCHEMA,
66 vol.Optional(CONF_ENTITY_CONFIG): {cv.entity_id: ALEXA_ENTITY_SCHEMA},
70 CONFIG_SCHEMA = vol.Schema(
73 CONF_FLASH_BRIEFINGS: {
74 vol.Required(CONF_PASSWORD): cv.string,
79 vol.Optional(CONF_UID): cv.string,
80 vol.Required(CONF_TITLE): cv.template,
81 vol.Optional(CONF_AUDIO): cv.template,
82 vol.Required(CONF_TEXT, default=
""): cv.template,
83 vol.Optional(CONF_DISPLAY_URL): cv.template,
90 CONF_SMART_HOME: vol.Any(SMART_HOME_SCHEMA,
None),
93 extra=vol.ALLOW_EXTRA,
97 async
def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
98 """Activate the Alexa component."""
99 if DOMAIN
not in config:
102 config = config[DOMAIN]
104 intent.async_setup(hass)
106 if flash_briefings_config := config.get(CONF_FLASH_BRIEFINGS):
107 flash_briefings.async_setup(hass, flash_briefings_config)
110 if CONF_SMART_HOME
in config:
111 smart_home_config: dict[str, Any] |
None = config[CONF_SMART_HOME]
113 await smart_home.async_setup(hass, smart_home_config)
bool async_setup(HomeAssistant hass, ConfigType config)