From b9f92b526bc64824017c3937c1fde49521c595d7 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 18 Jul 2023 12:17:31 +0200 Subject: [PATCH] Add prefix support to text selector (#96830) --- homeassistant/helpers/selector.py | 2 ++ tests/helpers/test_selector.py | 1 + 2 files changed, 3 insertions(+) diff --git a/homeassistant/helpers/selector.py b/homeassistant/helpers/selector.py index c996fcaf524..61ac81b0bca 100644 --- a/homeassistant/helpers/selector.py +++ b/homeassistant/helpers/selector.py @@ -1137,6 +1137,7 @@ class TextSelectorConfig(TypedDict, total=False): """Class to represent a text selector config.""" multiline: bool + prefix: str suffix: str type: TextSelectorType autocomplete: str @@ -1169,6 +1170,7 @@ class TextSelector(Selector[TextSelectorConfig]): CONFIG_SCHEMA = vol.Schema( { vol.Optional("multiline", default=False): bool, + vol.Optional("prefix"): str, 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. diff --git a/tests/helpers/test_selector.py b/tests/helpers/test_selector.py index 09cf79116a0..10dc825372f 100644 --- a/tests/helpers/test_selector.py +++ b/tests/helpers/test_selector.py @@ -581,6 +581,7 @@ def test_object_selector_schema(schema, valid_selections, invalid_selections) -> ({}, ("abc123",), (None,)), ({"multiline": True}, (), ()), ({"multiline": False, "type": "email"}, (), ()), + ({"prefix": "before", "suffix": "after"}, (), ()), ), ) def test_text_selector_schema(schema, valid_selections, invalid_selections) -> None: