From d4d798d71f51705f262a59f53070fe2307a2635d Mon Sep 17 00:00:00 2001 From: Jeff Schroeder Date: Wed, 19 Aug 2015 21:22:33 -0500 Subject: [PATCH] Error gracefully when unable to connect to home.nest.com --- homeassistant/components/thermostat/nest.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/thermostat/nest.py b/homeassistant/components/thermostat/nest.py index c724a4f6dea..656becd6a21 100644 --- a/homeassistant/components/thermostat/nest.py +++ b/homeassistant/components/thermostat/nest.py @@ -3,6 +3,7 @@ homeassistant.components.thermostat.nest ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adds support for Nest thermostats. """ +import socket import logging from homeassistant.components.thermostat import (ThermostatDevice, STATE_COOL, @@ -35,12 +36,16 @@ def setup_platform(hass, config, add_devices, discovery_info=None): return napi = nest.Nest(username, password) - - add_devices([ - NestThermostat(structure, device) - for structure in napi.structures - for device in structure.devices - ]) + try: + add_devices([ + NestThermostat(structure, device) + for structure in napi.structures + for device in structure.devices + ]) + except socket.error: + logger.error( + "Connection error logging into the nest web service" + ) class NestThermostat(ThermostatDevice):