Config validation for nest component
parent
5aa04de006
commit
faebc9e2c4
|
@ -4,7 +4,7 @@ Support for Nest thermostats.
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/thermostat.nest/
|
https://home-assistant.io/components/thermostat.nest/
|
||||||
"""
|
"""
|
||||||
import logging
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
|
|
||||||
|
@ -13,21 +13,22 @@ DOMAIN = 'nest'
|
||||||
|
|
||||||
NEST = None
|
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
|
# pylint: disable=unused-argument
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
"""Setup the Nest thermostat component."""
|
"""Setup the Nest thermostat component."""
|
||||||
global NEST
|
global NEST
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
username = config[DOMAIN].get(CONF_USERNAME)
|
username = config[DOMAIN].get(CONF_USERNAME)
|
||||||
password = config[DOMAIN].get(CONF_PASSWORD)
|
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
|
import nest
|
||||||
|
|
||||||
NEST = nest.Nest(username, password)
|
NEST = nest.Nest(username, password)
|
||||||
|
|
Loading…
Reference in New Issue