1 """Config flow to configure the GeoJSON events integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
8 import voluptuous
as vol
22 from .const
import DEFAULT_RADIUS_IN_M, DOMAIN
24 DATA_SCHEMA = vol.Schema(
26 vol.Required(CONF_URL): cv.string,
27 vol.Required(CONF_LOCATION): selector.LocationSelector(
28 selector.LocationSelectorConfig(radius=
True, icon=
"")
35 """Handle a GeoJSON events config flow."""
38 self, user_input: dict[str, Any] |
None =
None
39 ) -> ConfigFlowResult:
40 """Handle the start of the config flow."""
42 suggested_values: Mapping[str, Any] = {
44 CONF_LATITUDE: self.hass.config.latitude,
45 CONF_LONGITUDE: self.hass.config.longitude,
46 CONF_RADIUS: DEFAULT_RADIUS_IN_M,
50 DATA_SCHEMA, suggested_values
54 data_schema=data_schema,
57 url: str = user_input[CONF_URL]
58 location: dict[str, Any] = user_input[CONF_LOCATION]
59 latitude: float = location[CONF_LATITUDE]
60 longitude: float = location[CONF_LONGITUDE]
64 CONF_LATITUDE: latitude,
65 CONF_LONGITUDE: longitude,
69 title=f
"{url} ({latitude}, {longitude})",
72 CONF_LATITUDE: latitude,
73 CONF_LONGITUDE: longitude,
74 CONF_RADIUS: DistanceConverter.convert(
75 location[CONF_RADIUS],
77 UnitOfLength.KILOMETERS,
ConfigFlowResult async_step_user(self, dict[str, Any]|None 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)
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)
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)