mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Validate selectors in the service helper (#148857)
This commit is contained in:
parent
bcec29763f
commit
9db5b0b3b7
@ -19,6 +19,7 @@ from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
CONF_ACTION,
|
||||
CONF_ENTITY_ID,
|
||||
CONF_SELECTOR,
|
||||
CONF_SERVICE_DATA,
|
||||
CONF_SERVICE_DATA_TEMPLATE,
|
||||
CONF_SERVICE_TEMPLATE,
|
||||
@ -54,6 +55,7 @@ from . import (
|
||||
config_validation as cv,
|
||||
device_registry,
|
||||
entity_registry,
|
||||
selector,
|
||||
target as target_helpers,
|
||||
template,
|
||||
translation,
|
||||
@ -166,6 +168,7 @@ def validate_supported_feature(supported_feature: str) -> Any:
|
||||
# to their values. Full validation is done by hassfest.services
|
||||
_FIELD_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_SELECTOR): selector.validate_selector,
|
||||
vol.Optional("filter"): {
|
||||
vol.Optional("attribute"): {
|
||||
vol.Required(str): [vol.All(str, validate_attribute_option)],
|
||||
|
@ -987,7 +987,7 @@ async def test_async_get_all_descriptions_dot_keys(hass: HomeAssistant) -> None:
|
||||
"test_domain": {
|
||||
"test_service": {
|
||||
"description": "",
|
||||
"fields": {"test": {"selector": {"text": None}}},
|
||||
"fields": {"test": {"selector": {"text": {}}}},
|
||||
"name": "",
|
||||
}
|
||||
}
|
||||
@ -1013,6 +1013,13 @@ async def test_async_get_all_descriptions_filter(hass: HomeAssistant) -> None:
|
||||
- light.ColorMode.COLOR_TEMP
|
||||
selector:
|
||||
number:
|
||||
entity:
|
||||
selector:
|
||||
entity:
|
||||
filter:
|
||||
domain: alarm_control_panel
|
||||
supported_features:
|
||||
- alarm_control_panel.AlarmControlPanelEntityFeature.ARM_HOME
|
||||
advanced_stuff:
|
||||
fields:
|
||||
temperature:
|
||||
@ -1024,6 +1031,13 @@ async def test_async_get_all_descriptions_filter(hass: HomeAssistant) -> None:
|
||||
- light.ColorMode.COLOR_TEMP
|
||||
selector:
|
||||
number:
|
||||
entity:
|
||||
selector:
|
||||
entity:
|
||||
filter:
|
||||
domain: alarm_control_panel
|
||||
supported_features:
|
||||
- alarm_control_panel.AlarmControlPanelEntityFeature.ARM_HOME
|
||||
"""
|
||||
|
||||
domain = "test_domain"
|
||||
@ -1065,7 +1079,20 @@ async def test_async_get_all_descriptions_filter(hass: HomeAssistant) -> None:
|
||||
"attribute": {"supported_color_modes": ["color_temp"]},
|
||||
"supported_features": [1],
|
||||
},
|
||||
"selector": {"number": None},
|
||||
"selector": {"number": {}},
|
||||
},
|
||||
"entity": {
|
||||
"selector": {
|
||||
"entity": {
|
||||
"filter": [
|
||||
{
|
||||
"domain": ["alarm_control_panel"],
|
||||
"supported_features": [1],
|
||||
}
|
||||
],
|
||||
"multiple": False,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1074,7 +1101,20 @@ async def test_async_get_all_descriptions_filter(hass: HomeAssistant) -> None:
|
||||
"attribute": {"supported_color_modes": ["color_temp"]},
|
||||
"supported_features": [1],
|
||||
},
|
||||
"selector": {"number": None},
|
||||
"selector": {"number": {}},
|
||||
},
|
||||
"entity": {
|
||||
"selector": {
|
||||
"entity": {
|
||||
"filter": [
|
||||
{
|
||||
"domain": ["alarm_control_panel"],
|
||||
"supported_features": [1],
|
||||
}
|
||||
],
|
||||
"multiple": False,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"name": "",
|
||||
|
Loading…
x
Reference in New Issue
Block a user