From 652fe7e0f2991ff5aa8e17bb4a1d2f61ce5a29ca Mon Sep 17 00:00:00 2001 From: Jan Harkes Date: Tue, 12 Apr 2016 23:13:24 -0400 Subject: [PATCH] Service validation for garage_door component. --- homeassistant/components/garage_door/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/garage_door/__init__.py b/homeassistant/components/garage_door/__init__.py index 736949e474e..30d9a5e2e0b 100644 --- a/homeassistant/components/garage_door/__init__.py +++ b/homeassistant/components/garage_door/__init__.py @@ -7,10 +7,13 @@ at https://home-assistant.io/components/garage_door/ import logging import os +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.const import ( STATE_CLOSED, STATE_OPEN, STATE_UNKNOWN, SERVICE_CLOSE, SERVICE_OPEN, ATTR_ENTITY_ID) @@ -29,6 +32,10 @@ DISCOVERY_PLATFORMS = { wink.DISCOVER_GARAGE_DOORS: 'wink' } +GARAGE_DOOR_SERVICE_SCHEMA = vol.Schema({ + vol.Optional(ATTR_ENTITY_ID): cv.entity_ids, +}) + _LOGGER = logging.getLogger(__name__) @@ -73,10 +80,11 @@ def setup(hass, config): descriptions = load_yaml_config_file( os.path.join(os.path.dirname(__file__), 'services.yaml')) hass.services.register(DOMAIN, SERVICE_OPEN, handle_garage_door_service, - descriptions.get(SERVICE_OPEN)) + descriptions.get(SERVICE_OPEN), + schema=GARAGE_DOOR_SERVICE_SCHEMA) hass.services.register(DOMAIN, SERVICE_CLOSE, handle_garage_door_service, - descriptions.get(SERVICE_CLOSE)) - + descriptions.get(SERVICE_CLOSE), + schema=GARAGE_DOOR_SERVICE_SCHEMA) return True