From 2cdef7fb2fcc9defa6a58ce417f00217d9675df4 Mon Sep 17 00:00:00 2001 From: Johann Kellerman Date: Mon, 4 Jul 2016 03:33:23 +0200 Subject: [PATCH] Persistent_notification service description (#2407) * Persistent_notification service description * Add service name to services.yaml --- .../components/persistent_notification.py | 7 ++++++- homeassistant/components/services.yaml | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 homeassistant/components/services.yaml diff --git a/homeassistant/components/persistent_notification.py b/homeassistant/components/persistent_notification.py index 6b31da76849..cf030aee9b8 100644 --- a/homeassistant/components/persistent_notification.py +++ b/homeassistant/components/persistent_notification.py @@ -4,6 +4,7 @@ A component which is collecting configuration errors. For more details about this component, please refer to the documentation at https://home-assistant.io/components/persistent_notification/ """ +import os import logging import voluptuous as vol @@ -12,6 +13,7 @@ from homeassistant.exceptions import TemplateError from homeassistant.helpers import template, config_validation as cv from homeassistant.helpers.entity import generate_entity_id from homeassistant.util import slugify +from homeassistant.config import load_yaml_config_file DOMAIN = 'persistent_notification' ENTITY_ID_FORMAT = DOMAIN + '.{}' @@ -74,7 +76,10 @@ def setup(hass, config): hass.states.set(entity_id, message, attr) - hass.services.register(DOMAIN, SERVICE_CREATE, create_service, {}, + descriptions = load_yaml_config_file( + os.path.join(os.path.dirname(__file__), 'services.yaml')) + hass.services.register(DOMAIN, SERVICE_CREATE, create_service, + descriptions[DOMAIN][SERVICE_CREATE], SCHEMA_SERVICE_CREATE) return True diff --git a/homeassistant/components/services.yaml b/homeassistant/components/services.yaml new file mode 100644 index 00000000000..b7556152b04 --- /dev/null +++ b/homeassistant/components/services.yaml @@ -0,0 +1,16 @@ +persistent_notification: + create: + description: Show a notification in the frontend + + fields: + message: + description: Message body of the notification. [Templates accepted] + example: Please check your configuration.yaml. + + title: + description: Optional title for your notification. [Optional, Templates accepted] + example: Test notification + + notification_id: + description: Target ID of the notification, will replace a notification with the same Id. [Optional] + example: 1234