mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 18:39:30 +00:00
Make hassfest fail on services with device filter on targets (#152794)
This commit is contained in:
@@ -118,8 +118,20 @@ def _service_schema(targeted: bool, custom: bool) -> vol.Schema:
|
||||
)
|
||||
}
|
||||
|
||||
def raise_on_target_device_filter(value: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Raise error if target has a device filter."""
|
||||
if "device" in value:
|
||||
raise vol.Invalid(
|
||||
"Services do not support device filters on target, use a device "
|
||||
"selector instead"
|
||||
)
|
||||
return value
|
||||
|
||||
if targeted:
|
||||
schema_dict[vol.Required("target")] = selector.TargetSelector.CONFIG_SCHEMA
|
||||
schema_dict[vol.Required("target")] = vol.All(
|
||||
selector.TargetSelector.CONFIG_SCHEMA,
|
||||
raise_on_target_device_filter,
|
||||
)
|
||||
|
||||
if custom:
|
||||
schema_dict |= CUSTOM_INTEGRATION_EXTRA_SCHEMA_DICT
|
||||
|
||||
Reference in New Issue
Block a user