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