From 1e9e6927ebbb20ee66451e60979507de1b656e61 Mon Sep 17 00:00:00 2001 From: cdce8p <30130371+cdce8p@users.noreply.github.com> Date: Fri, 5 Jan 2018 09:02:10 +0100 Subject: [PATCH] Input Select - Added service description (#11456) --- homeassistant/components/input_select.py | 11 ++++++++ homeassistant/components/services.yaml | 32 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/homeassistant/components/input_select.py b/homeassistant/components/input_select.py index f16b029c1d7..5df26a83089 100644 --- a/homeassistant/components/input_select.py +++ b/homeassistant/components/input_select.py @@ -6,12 +6,14 @@ at https://home-assistant.io/components/input_select/ """ import asyncio import logging +import os import voluptuous as vol from homeassistant.const import ATTR_ENTITY_ID, CONF_ICON, CONF_NAME from homeassistant.loader import bind_hass import homeassistant.helpers.config_validation as cv +from homeassistant.config import load_yaml_config_file from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.restore_state import async_get_last_state @@ -129,6 +131,11 @@ def async_setup(hass, config): if not entities: return False + descriptions = yield from hass.async_add_job( + load_yaml_config_file, os.path.join( + os.path.dirname(__file__), 'services.yaml') + ) + @asyncio.coroutine def async_select_option_service(call): """Handle a calls to the input select option service.""" @@ -141,6 +148,7 @@ def async_setup(hass, config): hass.services.async_register( DOMAIN, SERVICE_SELECT_OPTION, async_select_option_service, + descriptions[DOMAIN][SERVICE_SELECT_OPTION], schema=SERVICE_SELECT_OPTION_SCHEMA) @asyncio.coroutine @@ -155,6 +163,7 @@ def async_setup(hass, config): hass.services.async_register( DOMAIN, SERVICE_SELECT_NEXT, async_select_next_service, + descriptions[DOMAIN][SERVICE_SELECT_NEXT], schema=SERVICE_SELECT_NEXT_SCHEMA) @asyncio.coroutine @@ -169,6 +178,7 @@ def async_setup(hass, config): hass.services.async_register( DOMAIN, SERVICE_SELECT_PREVIOUS, async_select_previous_service, + descriptions[DOMAIN][SERVICE_SELECT_PREVIOUS], schema=SERVICE_SELECT_PREVIOUS_SCHEMA) @asyncio.coroutine @@ -183,6 +193,7 @@ def async_setup(hass, config): hass.services.async_register( DOMAIN, SERVICE_SET_OPTIONS, async_set_options_service, + descriptions[DOMAIN][SERVICE_SET_OPTIONS], schema=SERVICE_SET_OPTIONS_SCHEMA) yield from component.async_add_entities(entities) diff --git a/homeassistant/components/services.yaml b/homeassistant/components/services.yaml index 90a1bbbc613..03c1d24184a 100644 --- a/homeassistant/components/services.yaml +++ b/homeassistant/components/services.yaml @@ -418,6 +418,38 @@ input_number: description: Entity id of the input number the should be decremented. example: 'input_number.threshold' +input_select: + select_option: + description: Select an option of an input select entity. + fields: + entity_id: + description: Entity id of the input select to select the value. + example: 'input_select.my_select' + option: + description: Option to be selected. + example: '"Item A"' + set_options: + description: Set the options of an input select entity. + fields: + entity_id: + description: Entity id of the input select to set the new options for. + example: 'input_select.my_select' + options: + description: Options for the input select entity. + example: '["Item A", "Item B", "Item C"]' + select_previous: + description: Select the previous options of an input select entity. + fields: + entity_id: + description: Entity id of the input select to select the previous value for. + example: 'input_select.my_select' + select_next: + description: Select the next options of an input select entity. + fields: + entity_id: + description: Entity id of the input select to select the next value for. + example: 'input_select.my_select' + homeassistant: check_config: description: Check the Home Assistant configuration files for errors. Errors will be displayed in the Home Assistant log.