Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions homeassistant/helpers/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
}
)

Expand Down Expand Up @@ -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
),
}
)

Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/test_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"),
),
Expand Down