mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Error gracefully when unable to connect to home.nest.com
This commit is contained in:
parent
3dc1dc6c6a
commit
d4d798d71f
@ -3,6 +3,7 @@ homeassistant.components.thermostat.nest
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Adds support for Nest thermostats.
|
Adds support for Nest thermostats.
|
||||||
"""
|
"""
|
||||||
|
import socket
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.thermostat import (ThermostatDevice, STATE_COOL,
|
from homeassistant.components.thermostat import (ThermostatDevice, STATE_COOL,
|
||||||
@ -35,12 +36,16 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
return
|
return
|
||||||
|
|
||||||
napi = nest.Nest(username, password)
|
napi = nest.Nest(username, password)
|
||||||
|
try:
|
||||||
add_devices([
|
add_devices([
|
||||||
NestThermostat(structure, device)
|
NestThermostat(structure, device)
|
||||||
for structure in napi.structures
|
for structure in napi.structures
|
||||||
for device in structure.devices
|
for device in structure.devices
|
||||||
])
|
])
|
||||||
|
except socket.error:
|
||||||
|
logger.error(
|
||||||
|
"Connection error logging into the nest web service"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NestThermostat(ThermostatDevice):
|
class NestThermostat(ThermostatDevice):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user