1 """Config flow for proximity."""
3 from __future__
import annotations
5 from typing
import Any, cast
7 import voluptuous
as vol
32 CONF_TRACKED_ENTITIES,
33 DEFAULT_PROXIMITY_ZONE,
38 RESULT_SUCCESS =
"success"
44 CONF_TRACKED_ENTITIES, default=user_input.get(CONF_TRACKED_ENTITIES, [])
47 domain=[DEVICE_TRACKER_DOMAIN, PERSON_DOMAIN], multiple=
True
51 CONF_IGNORED_ZONES, default=user_input.get(CONF_IGNORED_ZONES, [])
57 default=user_input.get(CONF_TOLERANCE, DEFAULT_TOLERANCE),
60 min=1, max=100, step=1, unit_of_measurement=UnitOfLength.METERS
67 """Handle a proximity config flow."""
72 if user_input
is None:
78 default=user_input.get(
79 CONF_ZONE, f
"{ZONE_DOMAIN}.{DEFAULT_PROXIMITY_ZONE}"
91 """Get the options flow for this handler."""
95 self, user_input: dict[str, Any] |
None =
None
96 ) -> ConfigFlowResult:
97 """Handle a flow initialized by the user."""
98 if user_input
is not None:
101 title = cast(State, self.hass.states.get(user_input[CONF_ZONE])).name
103 slugified_existing_entry_titles = [
107 possible_title = title
109 while slugify(possible_title)
in slugified_existing_entry_titles:
111 possible_title = f
"{title} {tries}"
122 """Handle a option flow."""
128 self, user_input: dict[str, Any] |
None =
None
129 ) -> ConfigFlowResult:
130 """Handle options flow."""
131 if user_input
is not None:
132 self.hass.config_entries.async_update_entry(
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
OptionsFlow async_get_options_flow(ConfigEntry config_entry)
vol.Schema _user_form_schema(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_init(self, dict[str, Any]|None user_input=None)
vol.Schema _user_form_schema(self, dict[str, Any] user_input)
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)
list[ConfigEntry] _async_current_entries(self, bool|None include_ignore=None)
None _async_abort_entries_match(self, dict[str, Any]|None match_dict=None)
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)
_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)
VolDictType _base_schema(dict[str, Any] user_input)