From 40e36126bcbcfe859ac70540a462163f5b32cb78 Mon Sep 17 00:00:00 2001 From: Jan Harkes Date: Tue, 12 Apr 2016 02:25:21 -0400 Subject: [PATCH] Service validation for rollershutter component. --- .../components/rollershutter/__init__.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/rollershutter/__init__.py b/homeassistant/components/rollershutter/__init__.py index 5c90aa99fe2..98bee419802 100644 --- a/homeassistant/components/rollershutter/__init__.py +++ b/homeassistant/components/rollershutter/__init__.py @@ -7,10 +7,13 @@ https://home-assistant.io/components/rollershutter/ import os import logging +import voluptuous as vol + from homeassistant.config import load_yaml_config_file from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity import Entity from homeassistant.helpers.config_validation import PLATFORM_SCHEMA # noqa +import homeassistant.helpers.config_validation as cv from homeassistant.components import group from homeassistant.const import ( SERVICE_MOVE_UP, SERVICE_MOVE_DOWN, SERVICE_STOP, @@ -33,6 +36,10 @@ _LOGGER = logging.getLogger(__name__) ATTR_CURRENT_POSITION = 'current_position' +ROLLERSHUTTER_SERVICE_SCHEMA = vol.Schema({ + vol.Optional(ATTR_ENTITY_ID): cv.entity_ids, +}) + def is_open(hass, entity_id=None): """Return if the roller shutter is open based on the statemachine.""" @@ -85,14 +92,16 @@ def setup(hass, config): hass.services.register(DOMAIN, SERVICE_MOVE_UP, handle_rollershutter_service, - descriptions.get(SERVICE_MOVE_UP)) + descriptions.get(SERVICE_MOVE_UP), + schema=ROLLERSHUTTER_SERVICE_SCHEMA) hass.services.register(DOMAIN, SERVICE_MOVE_DOWN, handle_rollershutter_service, - descriptions.get(SERVICE_MOVE_DOWN)) + descriptions.get(SERVICE_MOVE_DOWN), + schema=ROLLERSHUTTER_SERVICE_SCHEMA) hass.services.register(DOMAIN, SERVICE_STOP, handle_rollershutter_service, - descriptions.get(SERVICE_STOP)) - + descriptions.get(SERVICE_STOP), + schema=ROLLERSHUTTER_SERVICE_SCHEMA) return True