diff --git a/homeassistant/components/bluetooth/config_flow.py b/homeassistant/components/bluetooth/config_flow.py index ffebce2e521..0a414b36144 100644 --- a/homeassistant/components/bluetooth/config_flow.py +++ b/homeassistant/components/bluetooth/config_flow.py @@ -13,8 +13,12 @@ from bluetooth_adapters import ( import voluptuous as vol from homeassistant.components import onboarding -from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow +from homeassistant.config_entries import ConfigEntry, ConfigFlow from homeassistant.core import callback +from homeassistant.helpers.schema_config_entry_flow import ( + SchemaFlowFormStep, + SchemaOptionsFlowHandler, +) from homeassistant.helpers.typing import DiscoveryInfoType from . import models @@ -23,6 +27,15 @@ from .const import CONF_ADAPTER, CONF_DETAILS, CONF_PASSIVE, DOMAIN if TYPE_CHECKING: from homeassistant.data_entry_flow import FlowResult +OPTIONS_SCHEMA = vol.Schema( + { + vol.Required(CONF_PASSIVE, default=False): bool, + } +) +OPTIONS_FLOW = { + "init": SchemaFlowFormStep(OPTIONS_SCHEMA), +} + class BluetoothConfigFlow(ConfigFlow, domain=DOMAIN): """Config flow for Bluetooth.""" @@ -127,37 +140,12 @@ class BluetoothConfigFlow(ConfigFlow, domain=DOMAIN): @callback def async_get_options_flow( config_entry: ConfigEntry, - ) -> OptionsFlowHandler: + ) -> SchemaOptionsFlowHandler: """Get the options flow for this handler.""" - return OptionsFlowHandler(config_entry) + return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW) @classmethod @callback def async_supports_options_flow(cls, config_entry: ConfigEntry) -> bool: """Return options flow support for this handler.""" return bool(models.MANAGER and models.MANAGER.supports_passive_scan) - - -class OptionsFlowHandler(OptionsFlow): - """Handle the option flow for bluetooth.""" - - def __init__(self, config_entry: ConfigEntry) -> None: - """Initialize options flow.""" - self.config_entry = config_entry - - async def async_step_init( - self, user_input: dict[str, Any] | None = None - ) -> FlowResult: - """Handle options flow.""" - if user_input is not None: - return self.async_create_entry(title="", data=user_input) - - data_schema = vol.Schema( - { - vol.Required( - CONF_PASSIVE, - default=self.config_entry.options.get(CONF_PASSIVE, False), - ): bool, - } - ) - return self.async_show_form(step_id="init", data_schema=data_schema)