From c8ffac20b9b717b704c3c8a9d80e6fdc6b088a22 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Mon, 22 Feb 2021 16:26:46 +0100 Subject: [PATCH] Add name to services (#46905) --- homeassistant/components/light/services.yaml | 13 ++++++++++--- homeassistant/helpers/service.py | 6 ++++-- script/hassfest/services.py | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/light/services.yaml b/homeassistant/components/light/services.yaml index 2161ed3f81d..4f5d74cbbbb 100644 --- a/homeassistant/components/light/services.yaml +++ b/homeassistant/components/light/services.yaml @@ -1,7 +1,10 @@ # Describes the format for available light services 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: fields: transition: @@ -311,7 +314,8 @@ turn_on: text: turn_off: - description: Turn a light off + name: Turn off lights + description: Turns off one or more lights. target: fields: transition: @@ -340,7 +344,10 @@ turn_off: - short 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: fields: transition: diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index 01fb76ec1bc..a55ba8a84af 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -449,6 +449,7 @@ async def async_get_all_descriptions( # positives for things like scripts, that register as a service description = { + "name": yaml_description.get("name", ""), "description": yaml_description.get("description", ""), "fields": yaml_description.get("fields", {}), } @@ -472,8 +473,9 @@ def async_set_service_schema( hass.data.setdefault(SERVICE_DESCRIPTION_CACHE, {}) description = { - "description": schema.get("description") or "", - "fields": schema.get("fields") or {}, + "name": schema.get("name", ""), + "description": schema.get("description", ""), + "fields": schema.get("fields", {}), } hass.data[SERVICE_DESCRIPTION_CACHE][f"{domain}.{service}"] = description diff --git a/script/hassfest/services.py b/script/hassfest/services.py index 9037b0bb45e..62e9b2f88a1 100644 --- a/script/hassfest/services.py +++ b/script/hassfest/services.py @@ -37,6 +37,7 @@ FIELD_SCHEMA = vol.Schema( SERVICE_SCHEMA = vol.Schema( { vol.Required("description"): str, + vol.Optional("name"): str, vol.Optional("target"): vol.Any( selector.TargetSelector.CONFIG_SCHEMA, None # pylint: disable=no-member ),