1 """Config flow for Switch as X integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
8 import voluptuous
as vol
13 SchemaConfigFlowHandler,
15 wrapped_entity_config_entry_title,
18 from .const
import CONF_INVERT, CONF_TARGET_DOMAIN, DOMAIN
20 TARGET_DOMAIN_OPTIONS = [
33 vol.Required(CONF_ENTITY_ID): selector.EntitySelector(
34 selector.EntitySelectorConfig(domain=Platform.SWITCH),
36 vol.Optional(CONF_INVERT, default=
False): selector.BooleanSelector(),
37 vol.Required(CONF_TARGET_DOMAIN): selector.SelectSelector(
38 selector.SelectSelectorConfig(
39 options=TARGET_DOMAIN_OPTIONS, translation_key=
"target_domain"
49 vol.Schema({vol.Required(CONF_INVERT): selector.BooleanSelector()})
55 """Handle a config flow for Switch as X."""
57 config_flow = CONFIG_FLOW
58 options_flow = OPTIONS_FLOW
64 """Return config entry title and hide the wrapped entity if registered."""
66 registry = er.async_get(self.hass)
67 entity_entry = registry.async_get(options[CONF_ENTITY_ID])
68 if entity_entry
is not None and not entity_entry.hidden:
69 registry.async_update_entity(
70 options[CONF_ENTITY_ID], hidden_by=er.RegistryEntryHider.INTEGRATION
str async_config_entry_title(self, Mapping[str, Any] options)
str wrapped_entity_config_entry_title(HomeAssistant hass, str entity_id_or_uuid)