Skip to content

Commit

Permalink
fix: user input malformed bug in config flow
Browse files Browse the repository at this point in the history
  • Loading branch information
firstof9 committed Jul 21, 2021
1 parent 16a33ab commit f8630cc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions custom_components/mail_and_packages/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def _get_schema_step_2(
if user_input is None:
user_input = {}

def _get_default(key):
def _get_default(key: str, fallback_default: Any = None) -> None:
"""Gets default value for key."""
return user_input.get(key, default_dict.get(key))
return user_input.get(key, default_dict.get(key, fallback_default))

return vol.Schema(
{
Expand All @@ -185,7 +185,9 @@ def _get_default(key):
vol.Required(
CONF_RESOURCES, default=_get_default(CONF_RESOURCES)
): cv.multi_select(get_resources()),
vol.Optional(CONF_AMAZON_FWDS, default=_get_default(CONF_AMAZON_FWDS)): str,
vol.Optional(
CONF_AMAZON_FWDS, default=_get_default(CONF_AMAZON_FWDS, "")
): str,
vol.Optional(
CONF_SCAN_INTERVAL, default=_get_default(CONF_SCAN_INTERVAL)
): vol.All(vol.Coerce(int)),
Expand Down Expand Up @@ -220,7 +222,8 @@ def _get_default(key):
return vol.Schema(
{
vol.Optional(
CONF_CUSTOM_IMG_FILE, default=_get_default(CONF_CUSTOM_IMG_FILE)
CONF_CUSTOM_IMG_FILE,
default=_get_default(CONF_CUSTOM_IMG_FILE, DEFAULT_CUSTOM_IMG_FILE),
): str,
}
)
Expand Down

0 comments on commit f8630cc

Please sign in to comment.