From 5753da7dff829afcb3c6fc91e37a80b6f0c6bd4c Mon Sep 17 00:00:00 2001 From: G Johansson Date: Wed, 13 May 2026 16:42:47 +0200 Subject: [PATCH] Fix ObjectSelector when using other selectors (#170453) --- homeassistant/helpers/selector.py | 6 +++++- tests/helpers/test_selector.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/homeassistant/helpers/selector.py b/homeassistant/helpers/selector.py index 9eae351ae43a..eabedcbf5794 100644 --- a/homeassistant/helpers/selector.py +++ b/homeassistant/helpers/selector.py @@ -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"]: diff --git a/tests/helpers/test_selector.py b/tests/helpers/test_selector.py index cf9a2d77d210..b07af1588027 100644 --- a/tests/helpers/test_selector.py +++ b/tests/helpers/test_selector.py @@ -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})