diff --git a/homeassistant/helpers/selector.py b/homeassistant/helpers/selector.py index abd4d2e623e..c996fcaf524 100644 --- a/homeassistant/helpers/selector.py +++ b/homeassistant/helpers/selector.py @@ -453,6 +453,27 @@ class ColorTempSelector(Selector[ColorTempSelectorConfig]): return value +class ConditionSelectorConfig(TypedDict): + """Class to represent an action selector config.""" + + +@SELECTORS.register("condition") +class ConditionSelector(Selector[ConditionSelectorConfig]): + """Selector of an condition sequence (script syntax).""" + + selector_type = "condition" + + CONFIG_SCHEMA = vol.Schema({}) + + def __init__(self, config: ConditionSelectorConfig | None = None) -> None: + """Instantiate a selector.""" + super().__init__(config) + + def __call__(self, data: Any) -> Any: + """Validate the passed selection.""" + return vol.Schema(cv.CONDITIONS_SCHEMA)(data) + + class ConfigEntrySelectorConfig(TypedDict, total=False): """Class to represent a config entry selector config.""" diff --git a/tests/helpers/test_selector.py b/tests/helpers/test_selector.py index fd2dba4b084..09cf79116a0 100644 --- a/tests/helpers/test_selector.py +++ b/tests/helpers/test_selector.py @@ -1017,3 +1017,29 @@ def test_conversation_agent_selector_schema( ) -> None: """Test conversation agent selector.""" _test_selector("conversation_agent", schema, valid_selections, invalid_selections) + + +@pytest.mark.parametrize( + ("schema", "valid_selections", "invalid_selections"), + ( + ( + {}, + ( + [ + { + "condition": "numeric_state", + "entity_id": ["sensor.temperature"], + "below": 20, + } + ], + [], + ), + ("abc"), + ), + ), +) +def test_condition_selector_schema( + schema, valid_selections, invalid_selections +) -> None: + """Test condition sequence selector.""" + _test_selector("condition", schema, valid_selections, invalid_selections)