Input Select - Added service description (#11456)

This commit is contained in:
cdce8p 2018-01-05 09:02:10 +01:00 committed by Paulus Schoutsen
parent b7c7041873
commit 1e9e6927eb
2 changed files with 43 additions and 0 deletions

View File

@ -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)

View File

@ -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.