mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 09:23:17 -04:00
Fix ObjectSelector when using other selectors (#170453)
This commit is contained in:
@@ -1698,7 +1698,11 @@ class ObjectSelector(Selector[ObjectSelectorConfig]):
|
||||
if field_data.get("required") and field not in _config:
|
||||
raise vol.Invalid(f"Field {field} is required")
|
||||
if field in _config:
|
||||
selector(field_data["selector"])(_config[field]) # type: ignore[operator]
|
||||
field_selector = field_data["selector"]
|
||||
if isinstance(field_selector, Selector):
|
||||
field_selector(_config[field]) # type: ignore[operator]
|
||||
else:
|
||||
selector(field_selector)(_config[field]) # type: ignore[operator]
|
||||
|
||||
for key in _config:
|
||||
if key not in self.config["fields"]:
|
||||
|
||||
@@ -1366,6 +1366,12 @@ def test_object_selector_uses_selectors(snapshot: SnapshotAssertion) -> None:
|
||||
config = {selector_type: schema}
|
||||
selector.validate_selector(config)
|
||||
selector_instance = selector.selector(config)
|
||||
selector_instance(
|
||||
[
|
||||
{"name": "Test 1", "percentage": 50},
|
||||
{"name": "Test 2", "percentage": 70},
|
||||
]
|
||||
)
|
||||
|
||||
# Serialize selector
|
||||
selector_instance = selector.selector({selector_type: schema})
|
||||
|
||||
Reference in New Issue
Block a user