1 """Config flow for OpenWeatherMap."""
3 from __future__
import annotations
5 import voluptuous
as vol
33 from .utils
import build_data_and_options, validate_api_key
37 """Config flow for OpenWeatherMap."""
39 VERSION = CONFIG_FLOW_VERSION
44 config_entry: ConfigEntry,
45 ) -> OpenWeatherMapOptionsFlow:
46 """Get the options flow for this handler."""
50 """Handle a flow initialized by the user."""
52 description_placeholders = {}
54 if user_input
is not None:
55 latitude = user_input[CONF_LATITUDE]
56 longitude = user_input[CONF_LONGITUDE]
57 mode = user_input[CONF_MODE]
63 user_input[CONF_API_KEY], mode
69 title=user_input[CONF_NAME], data=data, options=options
74 vol.Required(CONF_API_KEY): str,
75 vol.Optional(CONF_NAME, default=DEFAULT_NAME): str,
77 CONF_LATITUDE, default=self.hass.config.latitude
80 CONF_LONGITUDE, default=self.hass.config.longitude
82 vol.Optional(CONF_MODE, default=DEFAULT_OWM_MODE): vol.In(OWM_MODES),
83 vol.Optional(CONF_LANGUAGE, default=DEFAULT_LANGUAGE): vol.In(
93 description_placeholders=description_placeholders,
101 """Manage the options."""
102 if user_input
is not None:
119 ): vol.In(OWM_MODES),
126 ): vol.In(LANGUAGES),
ConfigFlowResult async_step_user(self, user_input=None)
OpenWeatherMapOptionsFlow async_get_options_flow(ConfigEntry config_entry)
def _get_options_schema(self)
ConfigFlowResult async_step_init(self, dict|None user_input=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_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)
def validate_api_key(api_key, mode)
tuple[dict[str, Any], dict[str, Any]] build_data_and_options(dict[str, Any] combined_data)