forked from home-assistant/core
Update format
This commit is contained in:
@@ -1113,20 +1113,22 @@ class NumberSelector(Selector[NumberSelectorConfig]):
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
class ObjectSchemaDict(TypedDict):
|
class ObjectSelectorField(TypedDict):
|
||||||
"""Class to represent a select option dict."""
|
"""Class to represent a select option dict."""
|
||||||
|
|
||||||
name: str
|
label: str
|
||||||
|
required: bool
|
||||||
selector: dict[str, Any]
|
selector: dict[str, Any]
|
||||||
|
|
||||||
|
|
||||||
class ObjectSelectorConfig(BaseSelectorConfig):
|
class ObjectSelectorConfig(BaseSelectorConfig):
|
||||||
"""Class to represent an object selector config."""
|
"""Class to represent an object selector config."""
|
||||||
|
|
||||||
schema: list[ObjectSchemaDict]
|
fields: dict[str, ObjectSelectorField]
|
||||||
multiple: bool
|
multiple: bool
|
||||||
label_key: str
|
label_field: str
|
||||||
description: bool
|
description_field: bool
|
||||||
|
translation_key: str
|
||||||
|
|
||||||
|
|
||||||
@SELECTORS.register("object")
|
@SELECTORS.register("object")
|
||||||
@@ -1137,15 +1139,17 @@ class ObjectSelector(Selector[ObjectSelectorConfig]):
|
|||||||
|
|
||||||
CONFIG_SCHEMA = BASE_SELECTOR_CONFIG_SCHEMA.extend(
|
CONFIG_SCHEMA = BASE_SELECTOR_CONFIG_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
vol.Optional("schema"): [
|
vol.Optional("fields"): {
|
||||||
{
|
str: {
|
||||||
vol.Required("name"): str,
|
|
||||||
vol.Required("selector"): dict,
|
vol.Required("selector"): dict,
|
||||||
|
vol.Optional("required"): bool,
|
||||||
|
vol.Optional("label"): str,
|
||||||
}
|
}
|
||||||
],
|
},
|
||||||
vol.Optional("label_key"): str,
|
|
||||||
vol.Optional("description_key"): str,
|
|
||||||
vol.Optional("multiple", default=False): bool,
|
vol.Optional("multiple", default=False): bool,
|
||||||
|
vol.Optional("label_field"): str,
|
||||||
|
vol.Optional("description_field"): str,
|
||||||
|
vol.Optional("translation_key"): str,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -594,13 +594,18 @@ def test_action_selector_schema(schema, valid_selections, invalid_selections) ->
|
|||||||
({}, ("abc123",), ()),
|
({}, ("abc123",), ()),
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
"schema": [
|
"fields": {
|
||||||
{"name": "name", "selector": {"text": {}}},
|
"name": {
|
||||||
{"name": "percentage", "selector": {"number": {}}},
|
"required": True,
|
||||||
],
|
"selector": {"text": {}},
|
||||||
|
},
|
||||||
|
"percentage": {
|
||||||
|
"selector": {"number": {}},
|
||||||
|
},
|
||||||
|
},
|
||||||
"multiple": True,
|
"multiple": True,
|
||||||
"label_key": "name",
|
"label_field": "name",
|
||||||
"description_key": "percentage",
|
"description_field": "percentage",
|
||||||
},
|
},
|
||||||
(),
|
(),
|
||||||
(),
|
(),
|
||||||
|
Reference in New Issue
Block a user