From d8c989f7326cc65bd6ae8eccf4ab0c28b2a2e844 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Tue, 18 Jul 2023 17:36:35 +0200 Subject: [PATCH] Make default theme selectable for set theme service (#96849) --- homeassistant/components/frontend/services.yaml | 1 + homeassistant/helpers/selector.py | 6 +++++- tests/helpers/test_selector.py | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/frontend/services.yaml b/homeassistant/components/frontend/services.yaml index 2a562ab348a..0cc88baf32f 100644 --- a/homeassistant/components/frontend/services.yaml +++ b/homeassistant/components/frontend/services.yaml @@ -11,6 +11,7 @@ set_theme: example: "default" selector: theme: + include_default: true mode: name: Mode description: The mode the theme is for. diff --git a/homeassistant/helpers/selector.py b/homeassistant/helpers/selector.py index 61ac81b0bca..c7087918cf0 100644 --- a/homeassistant/helpers/selector.py +++ b/homeassistant/helpers/selector.py @@ -1201,7 +1201,11 @@ class ThemeSelector(Selector[ThemeSelectorConfig]): selector_type = "theme" - CONFIG_SCHEMA = vol.Schema({}) + CONFIG_SCHEMA = vol.Schema( + { + vol.Optional("include_default", default=False): cv.boolean, + } + ) def __init__(self, config: ThemeSelectorConfig | None = None) -> None: """Instantiate a selector.""" diff --git a/tests/helpers/test_selector.py b/tests/helpers/test_selector.py index 10dc825372f..c1d5f76ea78 100644 --- a/tests/helpers/test_selector.py +++ b/tests/helpers/test_selector.py @@ -747,6 +747,11 @@ def test_icon_selector_schema(schema, valid_selections, invalid_selections) -> N ("abc",), (None,), ), + ( + {"include_default": True}, + ("abc",), + (None,), + ), ), ) def test_theme_selector_schema(schema, valid_selections, invalid_selections) -> None: