1 """Config flow to configure the GeoNet NZ Quakes integration."""
6 import voluptuous
as vol
18 CONF_MINIMUM_MAGNITUDE,
20 DEFAULT_MINIMUM_MAGNITUDE,
23 DEFAULT_SCAN_INTERVAL,
27 DATA_SCHEMA = vol.Schema(
29 vol.Optional(CONF_MMI, default=DEFAULT_MMI): vol.All(
30 vol.Coerce(int), vol.Range(min=-1, max=8)
32 vol.Optional(CONF_RADIUS, default=DEFAULT_RADIUS): cv.positive_int,
36 _LOGGER = logging.getLogger(__name__)
40 """Handle a GeoNet NZ Quakes config flow."""
43 """Show the form to the user."""
45 step_id=
"user", data_schema=DATA_SCHEMA, errors=errors
or {}
48 async
def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
49 """Import a config entry from configuration.yaml."""
53 self, user_input: dict[str, Any] |
None =
None
54 ) -> ConfigFlowResult:
55 """Handle the start of the config flow."""
56 _LOGGER.debug(
"User input: %s", user_input)
60 latitude = user_input.get(CONF_LATITUDE, self.hass.config.latitude)
61 user_input[CONF_LATITUDE] = latitude
62 longitude = user_input.get(CONF_LONGITUDE, self.hass.config.longitude)
63 user_input[CONF_LONGITUDE] = longitude
65 identifier = f
"{user_input[CONF_LATITUDE]}, {user_input[CONF_LONGITUDE]}"
70 scan_interval = user_input.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
71 user_input[CONF_SCAN_INTERVAL] = scan_interval.total_seconds()
73 minimum_magnitude = user_input.get(
74 CONF_MINIMUM_MAGNITUDE, DEFAULT_MINIMUM_MAGNITUDE
76 user_input[CONF_MINIMUM_MAGNITUDE] = minimum_magnitude
def _show_form(self, 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)
config_entries.ConfigFlowResult async_step_import(self, dict[str, Any]|None _)