1 """Config flow to configure the GDACS integration."""
6 import voluptuous
as vol
17 from .const
import CONF_CATEGORIES, DEFAULT_RADIUS, DEFAULT_SCAN_INTERVAL, DOMAIN
19 DATA_SCHEMA = vol.Schema(
20 {vol.Optional(CONF_RADIUS, default=DEFAULT_RADIUS): cv.positive_int}
23 _LOGGER = logging.getLogger(__name__)
27 """Handle a GDACS config flow."""
30 self, errors: dict[str, str] |
None =
None
31 ) -> ConfigFlowResult:
32 """Show the form to the user."""
34 step_id=
"user", data_schema=DATA_SCHEMA, errors=errors
or {}
38 self, user_input: dict[str, Any] |
None =
None
39 ) -> ConfigFlowResult:
40 """Handle the start of the config flow."""
41 _LOGGER.debug(
"User input: %s", user_input)
45 latitude = user_input.get(CONF_LATITUDE, self.hass.config.latitude)
46 user_input[CONF_LATITUDE] = latitude
47 longitude = user_input.get(CONF_LONGITUDE, self.hass.config.longitude)
48 user_input[CONF_LONGITUDE] = longitude
50 identifier = f
"{user_input[CONF_LATITUDE]}, {user_input[CONF_LONGITUDE]}"
55 scan_interval = user_input.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
56 user_input[CONF_SCAN_INTERVAL] = scan_interval.total_seconds()
58 categories = user_input.get(CONF_CATEGORIES, [])
59 user_input[CONF_CATEGORIES] = categories
ConfigFlowResult _show_form(self, dict[str, str]|None errors=None)
None _abort_if_unique_id_configured(self, dict[str, Any]|None updates=None, bool reload_on_update=True, *str error="already_configured")
ConfigEntry|None async_set_unique_id(self, str|None unique_id=None, *bool raise_on_progress=True)
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_step_user(self, dict[str, Any]|None user_input=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)
_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)