diff --git a/homeassistant/helpers/selector.py b/homeassistant/helpers/selector.py index 51a54b3988f..ac5166911ff 100644 --- a/homeassistant/helpers/selector.py +++ b/homeassistant/helpers/selector.py @@ -459,7 +459,7 @@ class ColorTempSelector(Selector[ColorTempSelectorConfig]): class ConditionSelectorConfig(TypedDict): - """Class to represent an action selector config.""" + """Class to represent an condition selector config.""" @SELECTORS.register("condition") @@ -1280,6 +1280,27 @@ class TimeSelector(Selector[TimeSelectorConfig]): return cast(str, data) +class TriggerSelectorConfig(TypedDict): + """Class to represent an trigger selector config.""" + + +@SELECTORS.register("trigger") +class TriggerSelector(Selector[TriggerSelectorConfig]): + """Selector of a trigger sequence (script syntax).""" + + selector_type = "trigger" + + CONFIG_SCHEMA = vol.Schema({}) + + def __init__(self, config: TriggerSelectorConfig | None = None) -> None: + """Instantiate a selector.""" + super().__init__(config) + + def __call__(self, data: Any) -> Any: + """Validate the passed selection.""" + return vol.Schema(cv.TRIGGER_SCHEMA)(data) + + class FileSelectorConfig(TypedDict): """Class to represent a file selector config.""" diff --git a/tests/helpers/test_selector.py b/tests/helpers/test_selector.py index ee4749be346..1e449fd103a 100644 --- a/tests/helpers/test_selector.py +++ b/tests/helpers/test_selector.py @@ -1074,3 +1074,27 @@ def test_condition_selector_schema( ) -> None: """Test condition sequence selector.""" _test_selector("condition", schema, valid_selections, invalid_selections) + + +@pytest.mark.parametrize( + ("schema", "valid_selections", "invalid_selections"), + ( + ( + {}, + ( + [ + { + "platform": "numeric_state", + "entity_id": ["sensor.temperature"], + "below": 20, + } + ], + [], + ), + ("abc"), + ), + ), +) +def test_trigger_selector_schema(schema, valid_selections, invalid_selections) -> None: + """Test trigger sequence selector.""" + _test_selector("trigger", schema, valid_selections, invalid_selections)