mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 05:37:44 +00:00
Improve validation for media selector (#147768)
This commit is contained in:
parent
217fbb2849
commit
be6b624081
@ -1043,9 +1043,18 @@ class MediaSelector(Selector[MediaSelectorConfig]):
|
||||
"""Instantiate a selector."""
|
||||
super().__init__(config)
|
||||
|
||||
def __call__(self, data: Any) -> dict[str, float]:
|
||||
def __call__(self, data: Any) -> dict[str, str]:
|
||||
"""Validate the passed selection."""
|
||||
media: dict[str, float] = self.DATA_SCHEMA(data)
|
||||
schema = self.DATA_SCHEMA.schema.copy()
|
||||
|
||||
if "accept" in self.config:
|
||||
# If accept is set, the entity_id field will not be present
|
||||
schema.pop("entity_id", None)
|
||||
else:
|
||||
# If accept is not set, the entity_id field is required
|
||||
schema[vol.Required("entity_id")] = cv.entity_id_or_uuid
|
||||
|
||||
media: dict[str, str] = self.DATA_SCHEMA(data)
|
||||
return media
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user