1
0
mirror of https://github.com/home-assistant/core.git synced 2026-06-29 10:46:02 +01:00

Ensure HA script and Python script services have a name (#47204)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Philip Allgaier
2021-03-31 15:09:45 +02:00
committed by GitHub
parent bee55a0494
commit 6fe04f40a2
6 changed files with 39 additions and 4 deletions
@@ -19,7 +19,7 @@ from RestrictedPython.Guards import (
)
import voluptuous as vol
from homeassistant.const import SERVICE_RELOAD
from homeassistant.const import CONF_DESCRIPTION, CONF_NAME, SERVICE_RELOAD
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.service import async_set_service_schema
from homeassistant.loader import bind_hass
@@ -71,6 +71,8 @@ ALLOWED_DT_UTIL = {
"get_age",
}
CONF_FIELDS = "fields"
class ScriptError(HomeAssistantError):
"""When a script error occurs."""
@@ -125,8 +127,9 @@ def discover_scripts(hass):
hass.services.register(DOMAIN, name, python_script_service_handler)
service_desc = {
"description": services_dict.get(name, {}).get("description", ""),
"fields": services_dict.get(name, {}).get("fields", {}),
CONF_NAME: services_dict.get(name, {}).get("name", name),
CONF_DESCRIPTION: services_dict.get(name, {}).get("description", ""),
CONF_FIELDS: services_dict.get(name, {}).get("fields", {}),
}
async_set_service_schema(hass, DOMAIN, name, service_desc)
@@ -1,4 +1,5 @@
# Describes the format for available python_script services
reload:
name: Reload
description: Reload all available python_scripts