From 31be2726651b8fb6864ae1fae54a4276de6fb401 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 1 Sep 2016 18:38:37 +0200 Subject: [PATCH 1/2] Update configuration check --- homeassistant/components/binary_sensor/nest.py | 16 ++++++++-------- homeassistant/components/nest.py | 17 +++++++++-------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/binary_sensor/nest.py b/homeassistant/components/binary_sensor/nest.py index 9f963b730b53aa..4dfe4d58b9960f 100644 --- a/homeassistant/components/binary_sensor/nest.py +++ b/homeassistant/components/binary_sensor/nest.py @@ -6,12 +6,12 @@ """ import voluptuous as vol -import homeassistant.components.nest as nest -from homeassistant.components.binary_sensor import BinarySensorDevice +from homeassistant.components.binary_sensor import ( + BinarySensorDevice, PLATFORM_SCHEMA) from homeassistant.components.sensor.nest import NestSensor -from homeassistant.const import ( - CONF_PLATFORM, CONF_SCAN_INTERVAL, CONF_MONITORED_CONDITIONS -) +from homeassistant.const import (CONF_SCAN_INTERVAL, CONF_MONITORED_CONDITIONS) +import homeassistant.components.nest as nest +import homeassistant.helpers.config_validation as cv DEPENDENCIES = ['nest'] BINARY_TYPES = ['fan', @@ -25,11 +25,11 @@ 'hvac_emer_heat_state', 'online'] -PLATFORM_SCHEMA = vol.Schema({ - vol.Required(CONF_PLATFORM): nest.DOMAIN, +PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_SCAN_INTERVAL): vol.All(vol.Coerce(int), vol.Range(min=1)), - vol.Required(CONF_MONITORED_CONDITIONS): [vol.In(BINARY_TYPES)], + vol.Required(CONF_MONITORED_CONDITIONS): + vol.All(cv.ensure_list, [vol.In(BINARY_TYPES)]), }) diff --git a/homeassistant/components/nest.py b/homeassistant/components/nest.py index 430b9baa956470..d875ab0e2c0cce 100644 --- a/homeassistant/components/nest.py +++ b/homeassistant/components/nest.py @@ -1,18 +1,21 @@ """ -Support for Nest thermostats and protect smoke alarms. +Support for Nest devices. -For more details about this platform, please refer to the documentation at -https://home-assistant.io/components/climate.nest/ +For more details about this component, please refer to the documentation at +https://home-assistant.io/components/nest/ """ import logging import socket import voluptuous as vol + import homeassistant.helpers.config_validation as cv +from homeassistant.const import (CONF_PASSWORD, CONF_USERNAME, CONF_STRUCTURE) -from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, CONF_STRUCTURE +_LOGGER = logging.getLogger(__name__) REQUIREMENTS = ['python-nest==2.9.2'] + DOMAIN = 'nest' NEST = None @@ -21,14 +24,12 @@ CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({ - vol.Required(CONF_USERNAME): str, - vol.Required(CONF_PASSWORD): str, + vol.Required(CONF_USERNAME): cv.string, + vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_STRUCTURE): vol.All(cv.ensure_list, cv.string) }) }, extra=vol.ALLOW_EXTRA) -_LOGGER = logging.getLogger(__name__) - def devices(): """Generator returning list of devices and their location.""" From f6ac396c0c508039c244333d1d74ad319c90b734 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 1 Sep 2016 18:40:31 +0200 Subject: [PATCH 2/2] Extend platform --- homeassistant/components/climate/nest.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/climate/nest.py b/homeassistant/components/climate/nest.py index 39746bff601394..585ff804526d8f 100644 --- a/homeassistant/components/climate/nest.py +++ b/homeassistant/components/climate/nest.py @@ -8,13 +8,12 @@ import homeassistant.components.nest as nest from homeassistant.components.climate import ( - STATE_COOL, STATE_HEAT, STATE_IDLE, ClimateDevice) -from homeassistant.const import TEMP_CELSIUS, CONF_PLATFORM, CONF_SCAN_INTERVAL + STATE_COOL, STATE_HEAT, STATE_IDLE, ClimateDevice, PLATFORM_SCHEMA) +from homeassistant.const import TEMP_CELSIUS, CONF_SCAN_INTERVAL DEPENDENCIES = ['nest'] -PLATFORM_SCHEMA = vol.Schema({ - vol.Required(CONF_PLATFORM): nest.DOMAIN, +PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_SCAN_INTERVAL): vol.All(vol.Coerce(int), vol.Range(min=1)), })