mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
Fix service schema to allow for services without any fields/properties (#96346)
This commit is contained in:
parent
50442c5688
commit
f25d5a157a
@ -633,8 +633,8 @@ async def async_get_all_descriptions(
|
|||||||
# service.async_set_service_schema for the dynamic
|
# service.async_set_service_schema for the dynamic
|
||||||
# service
|
# service
|
||||||
|
|
||||||
yaml_description = domain_yaml.get( # type: ignore[union-attr]
|
yaml_description = (
|
||||||
service_name, {}
|
domain_yaml.get(service_name) or {} # type: ignore[union-attr]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Don't warn for missing services, because it triggers false
|
# Don't warn for missing services, because it triggers false
|
||||||
|
@ -46,13 +46,18 @@ FIELD_SCHEMA = vol.Schema(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
SERVICE_SCHEMA = vol.Schema(
|
SERVICE_SCHEMA = vol.Any(
|
||||||
{
|
vol.Schema(
|
||||||
vol.Optional("description"): str,
|
{
|
||||||
vol.Optional("name"): str,
|
vol.Optional("description"): str,
|
||||||
vol.Optional("target"): vol.Any(selector.TargetSelector.CONFIG_SCHEMA, None),
|
vol.Optional("name"): str,
|
||||||
vol.Optional("fields"): vol.Schema({str: FIELD_SCHEMA}),
|
vol.Optional("target"): vol.Any(
|
||||||
}
|
selector.TargetSelector.CONFIG_SCHEMA, None
|
||||||
|
),
|
||||||
|
vol.Optional("fields"): vol.Schema({str: FIELD_SCHEMA}),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
None,
|
||||||
)
|
)
|
||||||
|
|
||||||
SERVICES_SCHEMA = vol.Schema({cv.slug: SERVICE_SCHEMA})
|
SERVICES_SCHEMA = vol.Schema({cv.slug: SERVICE_SCHEMA})
|
||||||
@ -116,6 +121,8 @@ def validate_services(config: Config, integration: Integration) -> None:
|
|||||||
# For each service in the integration, check if the description if set,
|
# For each service in the integration, check if the description if set,
|
||||||
# if not, check if it's in the strings file. If not, add an error.
|
# if not, check if it's in the strings file. If not, add an error.
|
||||||
for service_name, service_schema in services.items():
|
for service_name, service_schema in services.items():
|
||||||
|
if service_schema is None:
|
||||||
|
continue
|
||||||
if "name" not in service_schema:
|
if "name" not in service_schema:
|
||||||
try:
|
try:
|
||||||
strings["services"][service_name]["name"]
|
strings["services"][service_name]["name"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user