1 """Config flow for Waze Travel Time integration."""
3 from __future__
import annotations
7 import voluptuous
as vol
31 CONF_AVOID_SUBSCRIPTION_ROADS,
32 CONF_AVOID_TOLL_ROADS,
49 from .helpers
import is_valid_config_entry
51 OPTIONS_SCHEMA = vol.Schema(
55 type=TextSelectorType.TEXT,
61 type=TextSelectorType.TEXT,
68 options=VEHICLE_TYPES,
69 mode=SelectSelectorMode.DROPDOWN,
70 translation_key=CONF_VEHICLE_TYPE,
77 mode=SelectSelectorMode.DROPDOWN,
78 translation_key=CONF_UNITS,
88 CONFIG_SCHEMA = vol.Schema(
90 vol.Required(CONF_NAME, default=DEFAULT_NAME):
TextSelector(),
96 mode=SelectSelectorMode.DROPDOWN,
97 translation_key=CONF_REGION,
106 """Get the default options."""
107 defaults = DEFAULT_OPTIONS.copy()
108 if hass.config.units
is US_CUSTOMARY_SYSTEM:
109 defaults[CONF_UNITS] = IMPERIAL_UNITS
114 """Handle an options flow for Waze Travel Time."""
117 """Handle the initial step."""
118 if user_input
is not None:
119 if user_input.get(CONF_INCL_FILTER)
is None:
120 user_input[CONF_INCL_FILTER] = DEFAULT_FILTER
121 if user_input.get(CONF_EXCL_FILTER)
is None:
122 user_input[CONF_EXCL_FILTER] = DEFAULT_FILTER
137 """Handle a config flow for Waze Travel Time."""
144 config_entry: ConfigEntry,
145 ) -> WazeOptionsFlow:
146 """Get the options flow for this handler."""
150 self, user_input: dict[str, Any] |
None =
None
151 ) -> ConfigFlowResult:
152 """Handle the initial step."""
154 user_input = user_input
or {}
157 user_input[CONF_REGION] = user_input[CONF_REGION].upper()
160 user_input[CONF_ORIGIN],
161 user_input[CONF_DESTINATION],
162 user_input[CONF_REGION],
167 title=user_input[CONF_NAME],
171 title=user_input.get(CONF_NAME, DEFAULT_NAME),
177 errors[
"base"] =
"cannot_connect"
178 user_input[CONF_REGION] = user_input[CONF_REGION].lower()
187 self, user_input: dict[str, Any] |
None =
None
188 ) -> ConfigFlowResult:
189 """Handle reconfiguration."""
191 data[CONF_REGION] = data[CONF_REGION].lower()
WazeOptionsFlow async_get_options_flow(ConfigEntry config_entry)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_reconfigure(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_init(self, user_input=None)
ConfigFlowResult async_create_entry(self, *str title, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None, Mapping[str, Any]|None options=None)
ConfigFlowResult async_update_reload_and_abort(self, ConfigEntry entry, *str|None|UndefinedType unique_id=UNDEFINED, str|UndefinedType title=UNDEFINED, Mapping[str, Any]|UndefinedType data=UNDEFINED, Mapping[str, Any]|UndefinedType data_updates=UNDEFINED, Mapping[str, Any]|UndefinedType options=UNDEFINED, str|UndefinedType reason=UNDEFINED, bool reload_even_if_entry_is_unchanged=True)
ConfigEntry _get_reconfigure_entry(self)
ConfigFlowResult async_show_form(self, *str|None step_id=None, vol.Schema|None data_schema=None, dict[str, str]|None errors=None, Mapping[str, str]|None description_placeholders=None, bool|None last_step=None, str|None preview=None)
ConfigEntry config_entry(self)
None config_entry(self, ConfigEntry value)
vol.Schema add_suggested_values_to_schema(self, vol.Schema data_schema, Mapping[str, Any]|None suggested_values)
_FlowResultT async_show_form(self, *str|None step_id=None, vol.Schema|None data_schema=None, dict[str, str]|None errors=None, Mapping[str, str]|None description_placeholders=None, bool|None last_step=None, str|None preview=None)
_FlowResultT async_create_entry(self, *str|None title=None, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None)
dict[str, str|bool|list[str]] default_options(HomeAssistant hass)
bool is_valid_config_entry(HomeAssistant hass, str origin, str destination, str region)