From d3fb69783d1f599756bf38f1aec3686710866a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=B8yer=20Iversen?= Date: Thu, 21 Apr 2016 16:57:28 +0200 Subject: [PATCH] Tellstick config validation --- homeassistant/components/light/tellstick.py | 4 ++++ homeassistant/components/switch/tellstick.py | 4 ++++ homeassistant/components/tellstick.py | 12 ++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/light/tellstick.py b/homeassistant/components/light/tellstick.py index 3571bd9737d..67d8c243ebc 100644 --- a/homeassistant/components/light/tellstick.py +++ b/homeassistant/components/light/tellstick.py @@ -4,12 +4,16 @@ Support for Tellstick lights. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/light.tellstick/ """ +import voluptuous as vol + from homeassistant.components import tellstick from homeassistant.components.light import ATTR_BRIGHTNESS, Light from homeassistant.components.tellstick import (DEFAULT_SIGNAL_REPETITIONS, ATTR_DISCOVER_DEVICES, ATTR_DISCOVER_CONFIG) +PLATFORM_SCHEMA = vol.Schema({vol.Required("platform"): tellstick.DOMAIN}) + # pylint: disable=unused-argument def setup_platform(hass, config, add_devices, discovery_info=None): diff --git a/homeassistant/components/switch/tellstick.py b/homeassistant/components/switch/tellstick.py index 8014244e828..a0cc4294b23 100644 --- a/homeassistant/components/switch/tellstick.py +++ b/homeassistant/components/switch/tellstick.py @@ -4,11 +4,15 @@ Support for Tellstick switches. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/switch.tellstick/ """ +import voluptuous as vol + from homeassistant.components import tellstick from homeassistant.components.tellstick import (ATTR_DISCOVER_DEVICES, ATTR_DISCOVER_CONFIG) from homeassistant.helpers.entity import ToggleEntity +PLATFORM_SCHEMA = vol.Schema({vol.Required("platform"): tellstick.DOMAIN}) + # pylint: disable=unused-argument def setup_platform(hass, config, add_devices, discovery_info=None): diff --git a/homeassistant/components/tellstick.py b/homeassistant/components/tellstick.py index 04927d9e652..8bb9d6a53f0 100644 --- a/homeassistant/components/tellstick.py +++ b/homeassistant/components/tellstick.py @@ -6,6 +6,7 @@ https://home-assistant.io/components/Tellstick/ """ import logging import threading +import voluptuous as vol from homeassistant import bootstrap from homeassistant.const import ( @@ -39,6 +40,14 @@ TELLSTICK_LOCK = threading.Lock() # Used from entities that register callback listeners TELLCORE_REGISTRY = None +CONFIG_SCHEMA = vol.Schema({ + DOMAIN: vol.Schema({ + vol.Optional(ATTR_SIGNAL_REPETITIONS, + default=DEFAULT_SIGNAL_REPETITIONS): + vol.Coerce(int), + }), +}, extra=vol.ALLOW_EXTRA) + def _discover(hass, config, found_devices, component_name): """Setup and send the discovery event.""" @@ -52,8 +61,7 @@ def _discover(hass, config, found_devices, component_name): bootstrap.setup_component(hass, component.DOMAIN, config) - signal_repetitions = config[DOMAIN].get( - ATTR_SIGNAL_REPETITIONS, DEFAULT_SIGNAL_REPETITIONS) + signal_repetitions = config[DOMAIN].get(ATTR_SIGNAL_REPETITIONS) hass.bus.fire(EVENT_PLATFORM_DISCOVERED, {ATTR_SERVICE: DISCOVERY_TYPES[component_name],