Update area and target selectors add sequence selector (#43831)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
3efda93875
commit
d93687b5ac
3 changed files with 84 additions and 4 deletions
|
@ -23,6 +23,7 @@ blueprint:
|
|||
number:
|
||||
min: 0
|
||||
max: 3600
|
||||
unit_of_measurement: seconds
|
||||
|
||||
# If motion is detected within the delay,
|
||||
# we restart the script.
|
||||
|
|
|
@ -79,7 +79,24 @@ class DeviceSelector(Selector):
|
|||
class AreaSelector(Selector):
|
||||
"""Selector of a single area."""
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({})
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional("entity"): vol.Schema(
|
||||
{
|
||||
vol.Optional("domain"): str,
|
||||
vol.Optional("device_class"): str,
|
||||
vol.Optional("integration"): str,
|
||||
}
|
||||
),
|
||||
vol.Optional("device"): vol.Schema(
|
||||
{
|
||||
vol.Optional("integration"): str,
|
||||
vol.Optional("manufacturer"): str,
|
||||
vol.Optional("model"): str,
|
||||
}
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@SELECTORS.register("number")
|
||||
|
@ -120,4 +137,28 @@ class TargetSelector(Selector):
|
|||
Value should follow cv.ENTITY_SERVICE_FIELDS format.
|
||||
"""
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({"entity": {"domain": str, "device_class": str}})
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional("entity"): vol.Schema(
|
||||
{
|
||||
vol.Optional("domain"): str,
|
||||
vol.Optional("device_class"): str,
|
||||
vol.Optional("integration"): str,
|
||||
}
|
||||
),
|
||||
vol.Optional("device"): vol.Schema(
|
||||
{
|
||||
vol.Optional("integration"): str,
|
||||
vol.Optional("manufacturer"): str,
|
||||
vol.Optional("model"): str,
|
||||
}
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@SELECTORS.register("action")
|
||||
class ActionSelector(Selector):
|
||||
"""Selector of an action sequence (script syntax)."""
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({})
|
||||
|
|
|
@ -79,7 +79,24 @@ def test_entity_selector_schema(schema):
|
|||
|
||||
@pytest.mark.parametrize(
|
||||
"schema",
|
||||
({},),
|
||||
(
|
||||
{},
|
||||
{"entity": {}},
|
||||
{"entity": {"domain": "light"}},
|
||||
{"entity": {"domain": "binary_sensor", "device_class": "motion"}},
|
||||
{
|
||||
"entity": {
|
||||
"domain": "binary_sensor",
|
||||
"device_class": "motion",
|
||||
"integration": "demo",
|
||||
}
|
||||
},
|
||||
{"device": {"integration": "demo", "model": "mock-model"}},
|
||||
{
|
||||
"entity": {"domain": "binary_sensor", "device_class": "motion"},
|
||||
"device": {"integration": "demo", "model": "mock-model"},
|
||||
},
|
||||
),
|
||||
)
|
||||
def test_area_selector_schema(schema):
|
||||
"""Test area selector."""
|
||||
|
@ -126,8 +143,29 @@ def test_time_selector_schema(schema):
|
|||
{"entity": {}},
|
||||
{"entity": {"domain": "light"}},
|
||||
{"entity": {"domain": "binary_sensor", "device_class": "motion"}},
|
||||
{
|
||||
"entity": {
|
||||
"domain": "binary_sensor",
|
||||
"device_class": "motion",
|
||||
"integration": "demo",
|
||||
}
|
||||
},
|
||||
{"device": {"integration": "demo", "model": "mock-model"}},
|
||||
{
|
||||
"entity": {"domain": "binary_sensor", "device_class": "motion"},
|
||||
"device": {"integration": "demo", "model": "mock-model"},
|
||||
},
|
||||
),
|
||||
)
|
||||
def test_target_selector_schema(schema):
|
||||
"""Test entity selector."""
|
||||
"""Test target selector."""
|
||||
selector.validate_selector({"target": schema})
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"schema",
|
||||
({},),
|
||||
)
|
||||
def test_action_selector_schema(schema):
|
||||
"""Test action sequence selector."""
|
||||
selector.validate_selector({"action": schema})
|
||||
|
|
Loading…
Add table
Reference in a new issue