mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
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
@ -23,6 +23,7 @@ blueprint:
|
|||||||
number:
|
number:
|
||||||
min: 0
|
min: 0
|
||||||
max: 3600
|
max: 3600
|
||||||
|
unit_of_measurement: seconds
|
||||||
|
|
||||||
# If motion is detected within the delay,
|
# If motion is detected within the delay,
|
||||||
# we restart the script.
|
# we restart the script.
|
||||||
|
@ -79,7 +79,24 @@ class DeviceSelector(Selector):
|
|||||||
class AreaSelector(Selector):
|
class AreaSelector(Selector):
|
||||||
"""Selector of a single area."""
|
"""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")
|
@SELECTORS.register("number")
|
||||||
@ -120,4 +137,28 @@ class TargetSelector(Selector):
|
|||||||
Value should follow cv.ENTITY_SERVICE_FIELDS format.
|
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(
|
@pytest.mark.parametrize(
|
||||||
"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_area_selector_schema(schema):
|
def test_area_selector_schema(schema):
|
||||||
"""Test area selector."""
|
"""Test area selector."""
|
||||||
@ -126,8 +143,29 @@ def test_time_selector_schema(schema):
|
|||||||
{"entity": {}},
|
{"entity": {}},
|
||||||
{"entity": {"domain": "light"}},
|
{"entity": {"domain": "light"}},
|
||||||
{"entity": {"domain": "binary_sensor", "device_class": "motion"}},
|
{"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):
|
def test_target_selector_schema(schema):
|
||||||
"""Test entity selector."""
|
"""Test target selector."""
|
||||||
selector.validate_selector({"target": schema})
|
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…
x
Reference in New Issue
Block a user