mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +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_AREA_ID,
|
||||||
CONF_LOCK_CODE_DIGITS,
|
CONF_LOCK_CODE_DIGITS,
|
||||||
DEFAULT_AREA_ID,
|
DEFAULT_AREA_ID,
|
||||||
DEFAULT_LOCK_CODE_DIGITS,
|
|
||||||
DEFAULT_NAME,
|
DEFAULT_NAME,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
LOGGER,
|
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):
|
class YaleConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Yale integration."""
|
"""Handle a config flow for Yale integration."""
|
||||||
@ -54,7 +61,7 @@ class YaleConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(config_entry: ConfigEntry) -> YaleOptionsFlowHandler:
|
def async_get_options_flow(config_entry: ConfigEntry) -> YaleOptionsFlowHandler:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return YaleOptionsFlowHandler(config_entry)
|
return YaleOptionsFlowHandler()
|
||||||
|
|
||||||
async def async_step_reauth(
|
async def async_step_reauth(
|
||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
@ -143,32 +150,18 @@ class YaleConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
class YaleOptionsFlowHandler(OptionsFlow):
|
class YaleOptionsFlowHandler(OptionsFlow):
|
||||||
"""Handle Yale options."""
|
"""Handle Yale options."""
|
||||||
|
|
||||||
def __init__(self, entry: ConfigEntry) -> None:
|
|
||||||
"""Initialize Yale options flow."""
|
|
||||||
self.entry = 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:
|
||||||
"""Manage Yale options."""
|
"""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_create_entry(data=user_input)
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="init",
|
step_id="init",
|
||||||
data_schema=vol.Schema(
|
data_schema=self.add_suggested_values_to_schema(
|
||||||
{
|
OPTIONS_SCHEMA,
|
||||||
vol.Optional(
|
self.config_entry.options,
|
||||||
CONF_LOCK_CODE_DIGITS,
|
|
||||||
description={
|
|
||||||
"suggested_value": self.entry.options.get(
|
|
||||||
CONF_LOCK_CODE_DIGITS, DEFAULT_LOCK_CODE_DIGITS
|
|
||||||
)
|
|
||||||
},
|
|
||||||
): int,
|
|
||||||
}
|
|
||||||
),
|
),
|
||||||
errors=errors,
|
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user