Use new helper properties in yeelight options flow (#129791)

This commit is contained in:
epenet 2024-11-04 16:09:50 +01:00 committed by GitHub
parent 4ac35d40cd
commit 365f8046ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,9 +58,11 @@ class YeelightConfigFlow(ConfigFlow, domain=DOMAIN):
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlowHandler: def async_get_options_flow(
config_entry: ConfigEntry,
) -> OptionsFlowHandler:
"""Return the options flow.""" """Return the options flow."""
return OptionsFlowHandler(config_entry) return OptionsFlowHandler()
def __init__(self) -> None: def __init__(self) -> None:
"""Initialize the config flow.""" """Initialize the config flow."""
@ -296,16 +298,12 @@ class YeelightConfigFlow(ConfigFlow, domain=DOMAIN):
class OptionsFlowHandler(OptionsFlow): class OptionsFlowHandler(OptionsFlow):
"""Handle a option flow for Yeelight.""" """Handle a option flow for Yeelight."""
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize the option flow."""
self._config_entry = config_entry
async def async_step_init( async def async_step_init(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
data = self._config_entry.data data = self.config_entry.data
options = self._config_entry.options options = self.config_entry.options
detected_model = data.get(CONF_DETECTED_MODEL) detected_model = data.get(CONF_DETECTED_MODEL)
model = options[CONF_MODEL] or detected_model model = options[CONF_MODEL] or detected_model