Add name to services (#46905)

This commit is contained in:
Franck Nijhof 2021-02-22 16:26:46 +01:00 committed by GitHub
parent 75e04f3a71
commit c8ffac20b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 5 deletions

View File

@ -1,7 +1,10 @@
# Describes the format for available light services # Describes the format for available light services
turn_on: turn_on:
description: Turn a light on name: Turn on lights
description: >
Turn on one or more lights and adjust properties of the light, even when
they are turned on already.
target: target:
fields: fields:
transition: transition:
@ -311,7 +314,8 @@ turn_on:
text: text:
turn_off: turn_off:
description: Turn a light off name: Turn off lights
description: Turns off one or more lights.
target: target:
fields: fields:
transition: transition:
@ -340,7 +344,10 @@ turn_off:
- short - short
toggle: toggle:
description: Toggles a light name: Toggle lights
description: >
Toggles one or more lights, from on to off, or, off to on, based on their
current state.
target: target:
fields: fields:
transition: transition:

View File

@ -449,6 +449,7 @@ async def async_get_all_descriptions(
# positives for things like scripts, that register as a service # positives for things like scripts, that register as a service
description = { description = {
"name": yaml_description.get("name", ""),
"description": yaml_description.get("description", ""), "description": yaml_description.get("description", ""),
"fields": yaml_description.get("fields", {}), "fields": yaml_description.get("fields", {}),
} }
@ -472,8 +473,9 @@ def async_set_service_schema(
hass.data.setdefault(SERVICE_DESCRIPTION_CACHE, {}) hass.data.setdefault(SERVICE_DESCRIPTION_CACHE, {})
description = { description = {
"description": schema.get("description") or "", "name": schema.get("name", ""),
"fields": schema.get("fields") or {}, "description": schema.get("description", ""),
"fields": schema.get("fields", {}),
} }
hass.data[SERVICE_DESCRIPTION_CACHE][f"{domain}.{service}"] = description hass.data[SERVICE_DESCRIPTION_CACHE][f"{domain}.{service}"] = description

View File

@ -37,6 +37,7 @@ FIELD_SCHEMA = vol.Schema(
SERVICE_SCHEMA = vol.Schema( SERVICE_SCHEMA = vol.Schema(
{ {
vol.Required("description"): str, vol.Required("description"): str,
vol.Optional("name"): str,
vol.Optional("target"): vol.Any( vol.Optional("target"): vol.Any(
selector.TargetSelector.CONFIG_SCHEMA, None # pylint: disable=no-member selector.TargetSelector.CONFIG_SCHEMA, None # pylint: disable=no-member
), ),