mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Add trigger selector for blueprint (#103050)
This commit is contained in:
parent
f5cc4dcf3e
commit
89a9e6c6e8
@ -459,7 +459,7 @@ class ColorTempSelector(Selector[ColorTempSelectorConfig]):
|
|||||||
|
|
||||||
|
|
||||||
class ConditionSelectorConfig(TypedDict):
|
class ConditionSelectorConfig(TypedDict):
|
||||||
"""Class to represent an action selector config."""
|
"""Class to represent an condition selector config."""
|
||||||
|
|
||||||
|
|
||||||
@SELECTORS.register("condition")
|
@SELECTORS.register("condition")
|
||||||
@ -1280,6 +1280,27 @@ class TimeSelector(Selector[TimeSelectorConfig]):
|
|||||||
return cast(str, data)
|
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 FileSelectorConfig(TypedDict):
|
||||||
"""Class to represent a file selector config."""
|
"""Class to represent a file selector config."""
|
||||||
|
|
||||||
|
@ -1074,3 +1074,27 @@ def test_condition_selector_schema(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Test condition sequence selector."""
|
"""Test condition sequence selector."""
|
||||||
_test_selector("condition", schema, valid_selections, invalid_selections)
|
_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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user