1 """Config flow to configure the GeoNet NZ Volcano integration."""
5 import voluptuous
as vol
21 DEFAULT_SCAN_INTERVAL,
30 """Return a set of configured GeoNet NZ Volcano instances."""
32 f
"{entry.data[CONF_LATITUDE]}, {entry.data[CONF_LONGITUDE]}"
33 for entry
in hass.config_entries.async_entries(DOMAIN)
38 """Handle a GeoNet NZ Volcano config flow."""
41 """Show the form to the user."""
42 data_schema = vol.Schema(
43 {vol.Optional(CONF_RADIUS, default=DEFAULT_RADIUS): cv.positive_int}
47 step_id=
"user", data_schema=data_schema, errors=errors
or {}
50 async
def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
51 """Import a config entry from configuration.yaml."""
55 self, user_input: dict[str, Any] |
None =
None
56 ) -> ConfigFlowResult:
57 """Handle the start of the config flow."""
61 latitude = user_input.get(CONF_LATITUDE, self.hass.config.latitude)
62 user_input[CONF_LATITUDE] = latitude
63 longitude = user_input.get(CONF_LONGITUDE, self.hass.config.longitude)
64 user_input[CONF_LONGITUDE] = longitude
66 identifier = f
"{user_input[CONF_LATITUDE]}, {user_input[CONF_LONGITUDE]}"
68 return await self.
_show_form_show_form({
"base":
"already_configured"})
70 if self.hass.config.units
is US_CUSTOMARY_SYSTEM:
71 user_input[CONF_UNIT_SYSTEM] = IMPERIAL_UNITS
73 user_input[CONF_UNIT_SYSTEM] = METRIC_UNITS
75 scan_interval = user_input.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
76 user_input[CONF_SCAN_INTERVAL] = scan_interval.total_seconds()
def _show_form(self, errors=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_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)
set[str] configured_instances(HomeAssistant hass)
config_entries.ConfigFlowResult async_step_import(self, dict[str, Any]|None _)