Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions homeassistant/helpers/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ class SingleEntitySelectorConfig(TypedDict, total=False):
# Integration linked to it with a config entry
vol.Optional("integration"): str,
# Manufacturer of device
vol.Optional("manufacturer"): str,
vol.Optional("manufacturer"): vol.Any(str, [str]),
# Model of device
vol.Optional("model"): str,
vol.Optional("model"): vol.Any(str, [str]),
# Device has to contain entities matching this selector
vol.Optional("entity"): SINGLE_ENTITY_SELECTOR_CONFIG_SCHEMA,
}
Expand All @@ -117,8 +117,8 @@ class SingleDeviceSelectorConfig(TypedDict, total=False):
"""Class to represent a single device selector config."""

integration: str
manufacturer: str
model: str
manufacturer: str | list[str]
model: str | list[str]
entity: SingleEntitySelectorConfig


Expand Down Expand Up @@ -397,8 +397,8 @@ class DeviceSelectorConfig(TypedDict, total=False):
"""Class to represent a device selector config."""

integration: str
manufacturer: str
model: str
manufacturer: str | list[str]
model: str | list[str]
entity: SingleEntitySelectorConfig
multiple: bool

Expand Down
27 changes: 27 additions & 0 deletions tests/helpers/test_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,15 @@ def default_converter(x):
({}, ("abc123",), (None,)),
({"integration": "zha"}, ("abc123",), (None,)),
({"manufacturer": "mock-manuf"}, ("abc123",), (None,)),
({"manufacturer": ["mock-manuf", "mock-manf-2"]}, ("abc123",), (None,)),
({"model": "mock-model"}, ("abc123",), (None,)),
({"model": ["mock-model", "mock-model-2"]}, ("abc123",), (None,)),
({"manufacturer": "mock-manuf", "model": "mock-model"}, ("abc123",), (None,)),
(
{"manufacturer": "mock-manuf", "model": ["mock-model", "mock-model-2"]},
("abc123",),
(None,),
),
(
{"integration": "zha", "manufacturer": "mock-manuf", "model": "mock-model"},
("abc123",),
Expand Down Expand Up @@ -201,6 +208,16 @@ def test_entity_selector_schema(schema, valid_selections, invalid_selections):
("abc123",),
(None,),
),
(
{
"device": {
"integration": "demo",
"model": ["mock-model", "mock-model-2"],
}
},
("abc123",),
(None,),
),
(
{
"entity": {"domain": "binary_sensor", "device_class": "motion"},
Expand Down Expand Up @@ -355,6 +372,16 @@ def test_state_selector_schema(schema, valid_selections, invalid_selections):
(),
),
({"device": {"integration": "demo", "model": "mock-model"}}, (), ()),
(
{
"device": {
"integration": "demo",
"model": ["mock-model", "mock-model-2"],
}
},
(),
(),
),
(
{
"entity": {"domain": "binary_sensor", "device_class": "motion"},
Expand Down