From faebc9e2c4c5124b9abcef5000a6490591818c73 Mon Sep 17 00:00:00 2001 From: Jan Harkes Date: Fri, 1 Apr 2016 10:31:11 -0400 Subject: [PATCH] Config validation for nest component --- homeassistant/components/nest.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/nest.py b/homeassistant/components/nest.py index efc51c771b6..a55fa6e2af3 100644 --- a/homeassistant/components/nest.py +++ b/homeassistant/components/nest.py @@ -4,7 +4,7 @@ Support for Nest thermostats. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/thermostat.nest/ """ -import logging +import voluptuous as vol from homeassistant.const import CONF_PASSWORD, CONF_USERNAME @@ -13,21 +13,22 @@ DOMAIN = 'nest' NEST = None +CONFIG_SCHEMA = vol.Schema({ + DOMAIN: vol.Schema({ + vol.Required(CONF_USERNAME): str, + vol.Required(CONF_PASSWORD): str + }) +}, extra=vol.ALLOW_EXTRA) + # pylint: disable=unused-argument def setup(hass, config): """Setup the Nest thermostat component.""" global NEST - logger = logging.getLogger(__name__) username = config[DOMAIN].get(CONF_USERNAME) password = config[DOMAIN].get(CONF_PASSWORD) - if username is None or password is None: - logger.error("Missing required configuration items %s or %s", - CONF_USERNAME, CONF_PASSWORD) - return - import nest NEST = nest.Nest(username, password)