diff --git a/script/hassfest/services.py b/script/hassfest/services.py index b47fa90d8bb..723a9ec9278 100644 --- a/script/hassfest/services.py +++ b/script/hassfest/services.py @@ -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