From 620d7a92f0f9e6d1a42c8dd2b16c74f704782366 Mon Sep 17 00:00:00 2001 From: Jan Harkes Date: Tue, 12 Apr 2016 22:52:14 -0400 Subject: [PATCH] Service validation for input_slider component. --- homeassistant/components/input_slider.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/input_slider.py b/homeassistant/components/input_slider.py index bef270f1387..a142fb364c7 100644 --- a/homeassistant/components/input_slider.py +++ b/homeassistant/components/input_slider.py @@ -6,7 +6,10 @@ at https://home-assistant.io/components/input_slider/ """ import logging +import voluptuous as vol + from homeassistant.const import ATTR_ENTITY_ID +import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_component import EntityComponent from homeassistant.util import slugify @@ -29,6 +32,11 @@ ATTR_STEP = 'step' SERVICE_SELECT_VALUE = 'select_value' +SERVICE_SELECT_VALUE_SCHEMA = vol.Schema({ + vol.Optional(ATTR_ENTITY_ID): cv.entity_ids, + vol.Required(ATTR_VALUE): vol.Coerce(int), +}) + def select_value(hass, entity_id, value): """Set input_slider to value.""" @@ -81,10 +89,11 @@ def setup(hass, config): target_inputs = component.extract_from_service(call) for input_slider in target_inputs: - input_slider.select_value(call.data.get(ATTR_VALUE)) + input_slider.select_value(call.data[ATTR_VALUE]) hass.services.register(DOMAIN, SERVICE_SELECT_VALUE, - select_value_service) + select_value_service, + schema=SERVICE_SELECT_VALUE_SCHEMA) component.add_entities(entities)