Nest config validation (#1810)

* Config validation for Nest platforms.
This commit is contained in:
Jan Harkes 2016-04-12 00:52:19 -04:00 committed by Paulus Schoutsen
parent 656e187729
commit 9d848731d9
4 changed files with 73 additions and 72 deletions

View file

@ -4,6 +4,9 @@ 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 socket
import voluptuous as vol
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
@ -20,14 +23,27 @@ CONFIG_SCHEMA = vol.Schema({
})
}, extra=vol.ALLOW_EXTRA)
_LOGGER = logging.getLogger(__name__)
def devices():
"""Generator returning list of devices and their location."""
try:
for structure in NEST.structures:
for device in structure.devices:
yield (structure, device)
except socket.error:
_LOGGER.error("Connection error logging into the nest web service.")
# pylint: disable=unused-argument
def setup(hass, config):
"""Setup the Nest thermostat component."""
global NEST
username = config[DOMAIN].get(CONF_USERNAME)
password = config[DOMAIN].get(CONF_PASSWORD)
conf = config[DOMAIN]
username = conf[CONF_USERNAME]
password = conf[CONF_PASSWORD]
import nest