From d477546e7602598d5de5302fe0e0a7c12b28e750 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 7 May 2022 20:57:48 -0700 Subject: [PATCH] Fix other enums in helpers (#71505) --- homeassistant/helpers/selector.py | 8 ++++++-- tests/helpers/test_selector.py | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/homeassistant/helpers/selector.py b/homeassistant/helpers/selector.py index 1ae0082c06f..87574949f4e 100644 --- a/homeassistant/helpers/selector.py +++ b/homeassistant/helpers/selector.py @@ -704,7 +704,9 @@ class SelectSelector(Selector): vol.Required("options"): vol.All(vol.Any([str], [select_option])), vol.Optional("multiple", default=False): cv.boolean, vol.Optional("custom_value", default=False): cv.boolean, - vol.Optional("mode"): vol.Coerce(SelectSelectorMode), + vol.Optional("mode"): vol.All( + vol.Coerce(SelectSelectorMode), lambda val: val.value + ), } ) @@ -827,7 +829,9 @@ class TextSelector(Selector): vol.Optional("suffix"): str, # The "type" controls the input field in the browser, the resulting # data can be any string so we don't validate it. - vol.Optional("type"): vol.Coerce(TextSelectorType), + vol.Optional("type"): vol.All( + vol.Coerce(TextSelectorType), lambda val: val.value + ), } ) diff --git a/tests/helpers/test_selector.py b/tests/helpers/test_selector.py index ed831026065..4cb924a520e 100644 --- a/tests/helpers/test_selector.py +++ b/tests/helpers/test_selector.py @@ -351,7 +351,7 @@ def test_object_selector_schema(schema, valid_selections, invalid_selections): ( ({}, ("abc123",), (None,)), ({"multiline": True}, (), ()), - ({"multiline": False}, (), ()), + ({"multiline": False, "type": "email"}, (), ()), ), ) def test_text_selector_schema(schema, valid_selections, invalid_selections): @@ -402,7 +402,7 @@ def test_text_selector_schema(schema, valid_selections, invalid_selections): (0, None, ["red"]), ), ( - {"options": [], "custom_value": True, "multiple": True}, + {"options": [], "custom_value": True, "multiple": True, "mode": "list"}, (["red"], ["green", "blue"], []), (0, None, "red"), ),