mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Improve code quality in yale_smart_alarm options flow (#129531)
* Improve code quality in yale_smart_alarm options flow * mods * Fix
This commit is contained in:
parent
6b33bf3961
commit
ab5c65b08c
@ -23,7 +23,6 @@ from .const import (
|
||||
CONF_AREA_ID,
|
||||
CONF_LOCK_CODE_DIGITS,
|
||||
DEFAULT_AREA_ID,
|
||||
DEFAULT_LOCK_CODE_DIGITS,
|
||||
DEFAULT_NAME,
|
||||
DOMAIN,
|
||||
LOGGER,
|
||||
@ -44,6 +43,14 @@ DATA_SCHEMA_AUTH = vol.Schema(
|
||||
}
|
||||
)
|
||||
|
||||
OPTIONS_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(
|
||||
CONF_LOCK_CODE_DIGITS,
|
||||
): int,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class YaleConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Yale integration."""
|
||||
@ -54,7 +61,7 @@ class YaleConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
@callback
|
||||
def async_get_options_flow(config_entry: ConfigEntry) -> YaleOptionsFlowHandler:
|
||||
"""Get the options flow for this handler."""
|
||||
return YaleOptionsFlowHandler(config_entry)
|
||||
return YaleOptionsFlowHandler()
|
||||
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
@ -143,32 +150,18 @@ class YaleConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
class YaleOptionsFlowHandler(OptionsFlow):
|
||||
"""Handle Yale options."""
|
||||
|
||||
def __init__(self, entry: ConfigEntry) -> None:
|
||||
"""Initialize Yale options flow."""
|
||||
self.entry = entry
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Manage Yale options."""
|
||||
errors: dict[str, Any] = {}
|
||||
|
||||
if user_input:
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(data=user_input)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="init",
|
||||
data_schema=vol.Schema(
|
||||
{
|
||||
vol.Optional(
|
||||
CONF_LOCK_CODE_DIGITS,
|
||||
description={
|
||||
"suggested_value": self.entry.options.get(
|
||||
CONF_LOCK_CODE_DIGITS, DEFAULT_LOCK_CODE_DIGITS
|
||||
)
|
||||
},
|
||||
): int,
|
||||
}
|
||||
data_schema=self.add_suggested_values_to_schema(
|
||||
OPTIONS_SCHEMA,
|
||||
self.config_entry.options,
|
||||
),
|
||||
errors=errors,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user