diff --git a/homeassistant/components/climate/nest.py b/homeassistant/components/climate/nest.py index f55d1d856eb..1b3c38ce449 100644 --- a/homeassistant/components/climate/nest.py +++ b/homeassistant/components/climate/nest.py @@ -4,15 +4,17 @@ Support for Nest thermostats. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/climate.nest/ """ +import logging import voluptuous as vol - import homeassistant.components.nest as nest from homeassistant.components.climate import ( STATE_COOL, STATE_HEAT, STATE_IDLE, ClimateDevice, PLATFORM_SCHEMA) from homeassistant.const import ( TEMP_CELSIUS, CONF_SCAN_INTERVAL, ATTR_TEMPERATURE) +from homeassistant.util.temperature import convert as convert_temperature DEPENDENCIES = ['nest'] +_LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_SCAN_INTERVAL): @@ -22,7 +24,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Nest thermostat.""" - add_devices([NestThermostat(structure, device) + temp_unit = hass.config.units.temperature_unit + add_devices([NestThermostat(structure, device, temp_unit) for structure, device in nest.devices()]) @@ -30,8 +33,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class NestThermostat(ClimateDevice): """Representation of a Nest thermostat.""" - def __init__(self, structure, device): + def __init__(self, structure, device, temp_unit): """Initialize the thermostat.""" + self._unit = temp_unit self.structure = structure self.device = device @@ -134,7 +138,9 @@ class NestThermostat(ClimateDevice): def set_temperature(self, **kwargs): """Set new target temperature.""" - temperature = kwargs.get(ATTR_TEMPERATURE) + temperature = convert_temperature(kwargs.get(ATTR_TEMPERATURE), + self._unit, TEMP_CELSIUS) + _LOGGER.debug("Nest set_temperature-input-value=%s", temperature) if temperature is None: return if self.device.mode == 'range': @@ -142,6 +148,7 @@ class NestThermostat(ClimateDevice): temperature = (temperature, self.target_temperature_high) elif self.target_temperature == self.target_temperature_high: temperature = (self.target_temperature_low, temperature) + _LOGGER.debug("Nest set_temperature-output-value=%s", temperature) self.device.target = temperature def set_operation_mode(self, operation_mode):