Skip to content
Snippets Groups Projects
Unverified Commit dc17bca0 authored by Franck Nijhof's avatar Franck Nijhof Committed by GitHub
Browse files

Add config entry selector (#77108)

parent f1075644
No related branches found
No related tags found
No related merge requests found
......@@ -318,6 +318,34 @@ class ColorTempSelector(Selector):
return value
class ConfigEntrySelectorConfig(TypedDict, total=False):
"""Class to represent a config entry selector config."""
integration: str
@SELECTORS.register("config_entry")
class ConfigEntrySelector(Selector):
"""Selector of a config entry."""
selector_type = "config_entry"
CONFIG_SCHEMA = vol.Schema(
{
vol.Optional("integration"): str,
}
)
def __init__(self, config: ConfigEntrySelectorConfig | None = None) -> None:
"""Instantiate a selector."""
super().__init__(config)
def __call__(self, data: Any) -> dict[str, str]:
"""Validate the passed selection."""
config: dict[str, str] = vol.Schema(str)(data)
return config
class DateSelectorConfig(TypedDict):
"""Class to represent a date selector config."""
......
......@@ -285,6 +285,26 @@ def test_boolean_selector_schema(schema, valid_selections, invalid_selections):
)
@pytest.mark.parametrize(
"schema,valid_selections,invalid_selections",
(
(
{},
("6b68b250388cbe0d620c92dd3acc93ec", "76f2e8f9a6491a1b580b3a8967c27ddd"),
(None, True, 1),
),
(
{"integration": "adguard"},
("6b68b250388cbe0d620c92dd3acc93ec", "76f2e8f9a6491a1b580b3a8967c27ddd"),
(None, True, 1),
),
),
)
def test_config_entry_selector_schema(schema, valid_selections, invalid_selections):
"""Test boolean selector."""
_test_selector("config_entry", schema, valid_selections, invalid_selections)
@pytest.mark.parametrize(
"schema,valid_selections,invalid_selections",
(({}, ("00:00:00",), ("blah", None)),),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment