From 9ea030f42e0da8ec125e28715a6e5ca00777653e Mon Sep 17 00:00:00 2001 From: Marcelo Moreira de Mello Date: Fri, 30 Sep 2016 01:17:13 -0400 Subject: [PATCH] Fixed issue #3574 - Temperature slider fixed on frontend on heat/cool mode (#3606) * Fixed issue #3574 - Temperature slider fixed on frontend on heat/cool mode * Fixed target_temperature to return None when self.is_away_mode_on is True --- homeassistant/components/climate/nest.py | 41 +++++++++++++++++------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/climate/nest.py b/homeassistant/components/climate/nest.py index 10abf812116..52b7c2bddd9 100644 --- a/homeassistant/components/climate/nest.py +++ b/homeassistant/components/climate/nest.py @@ -9,9 +9,10 @@ import voluptuous as vol import homeassistant.components.nest as nest from homeassistant.components.climate import ( STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_IDLE, ClimateDevice, - PLATFORM_SCHEMA, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW) + PLATFORM_SCHEMA, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, + ATTR_TEMPERATURE) from homeassistant.const import ( - TEMP_CELSIUS, CONF_SCAN_INTERVAL, STATE_ON, TEMP_FAHRENHEIT) + TEMP_CELSIUS, CONF_SCAN_INTERVAL, STATE_ON) from homeassistant.util.temperature import convert as convert_temperature DEPENDENCIES = ['nest'] @@ -40,6 +41,7 @@ class NestThermostat(ClimateDevice): self.structure = structure self.device = device self._fan_list = [STATE_ON, STATE_AUTO] + self._operation_list = [STATE_COOL, STATE_IDLE, STATE_HEAT] @property def name(self): @@ -57,10 +59,7 @@ class NestThermostat(ClimateDevice): @property def unit_of_measurement(self): """Return the unit of measurement.""" - if self.device.measurement_scale == 'F': - return TEMP_FAHRENHEIT - elif self.device.measurement_scale == 'C': - return TEMP_CELSIUS + return TEMP_CELSIUS @property def device_state_attributes(self): @@ -78,15 +77,23 @@ class NestThermostat(ClimateDevice): return self.device.temperature @property - def operation(self): + def current_operation(self): """Return current operation ie. heat, cool, idle.""" - if self.device.hvac_ac_state is True: + if self.device.hvac_ac_state: return STATE_COOL - elif self.device.hvac_heater_state is True: + elif self.device.hvac_heater_state: return STATE_HEAT else: return STATE_IDLE + @property + def target_temperature(self): + """Return the temperature we try to reach.""" + if self.device.mode != 'range' and not self.is_away_mode_on: + return self.device.target + else: + return None + @property def target_temperature_low(self): """Return the lower bound temperature we try to reach.""" @@ -95,7 +102,8 @@ class NestThermostat(ClimateDevice): return self.device.away_temperature[0] if self.device.mode == 'range': return self.device.target[0] - return self.target_temperature + else: + return None @property def target_temperature_high(self): @@ -105,7 +113,8 @@ class NestThermostat(ClimateDevice): return self.device.away_temperature[1] if self.device.mode == 'range': return self.device.target[1] - return self.target_temperature + else: + return None @property def is_away_mode_on(self): @@ -121,7 +130,10 @@ class NestThermostat(ClimateDevice): target_temp_low = convert_temperature(kwargs.get( ATTR_TARGET_TEMP_LOW), self._unit, TEMP_CELSIUS) - temp = (target_temp_low, target_temp_high) + if self.device.mode == 'range': + temp = (target_temp_low, target_temp_high) + else: + temp = kwargs.get(ATTR_TEMPERATURE) _LOGGER.debug("Nest set_temperature-output-value=%s", temp) self.device.target = temp @@ -129,6 +141,11 @@ class NestThermostat(ClimateDevice): """Set operation mode.""" self.device.mode = operation_mode + @property + def operation_list(self): + """List of available operation modes.""" + return self._operation_list + def turn_away_mode_on(self): """Turn away on.""" self.structure.away = True