From 39514be1f95d4e6fe8d1d85316f58b42e0c747d1 Mon Sep 17 00:00:00 2001 From: Marcelo Moreira de Mello Date: Fri, 30 Sep 2016 01:17:13 -0400 Subject: [PATCH 1/4] 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 From 099e983ca08a2368f0d4e8d6de7f6ed4eadbd7e3 Mon Sep 17 00:00:00 2001 From: Jeff Wilson Date: Fri, 30 Sep 2016 02:44:14 -0400 Subject: [PATCH 2/4] Nest operation modes (#3609) * Add ability to change Nest mode to all available options * Make Nest state reflect current operation not current operation mode * Update Nest sensor to use operation mode * Fix linting * Revert "Make Nest state reflect current operation not current operation mode" This reverts commit 573ba028d8ed11a2f228ca4b21cd7d88b7d0a919. Conflicts: homeassistant/components/climate/nest.py --- homeassistant/components/climate/nest.py | 27 +++++++++++++++++------- homeassistant/components/sensor/nest.py | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/climate/nest.py b/homeassistant/components/climate/nest.py index 52b7c2bddd9..2d3b95bb5cf 100644 --- a/homeassistant/components/climate/nest.py +++ b/homeassistant/components/climate/nest.py @@ -12,7 +12,7 @@ from homeassistant.components.climate import ( PLATFORM_SCHEMA, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, ATTR_TEMPERATURE) from homeassistant.const import ( - TEMP_CELSIUS, CONF_SCAN_INTERVAL, STATE_ON) + TEMP_CELSIUS, CONF_SCAN_INTERVAL, STATE_ON, STATE_OFF, STATE_UNKNOWN) from homeassistant.util.temperature import convert as convert_temperature DEPENDENCIES = ['nest'] @@ -31,7 +31,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): for structure, device in nest.devices()]) -# pylint: disable=abstract-method +# pylint: disable=abstract-method,too-many-public-methods class NestThermostat(ClimateDevice): """Representation of a Nest thermostat.""" @@ -41,7 +41,8 @@ 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] + self._operation_list = [STATE_HEAT, STATE_COOL, STATE_AUTO, + STATE_OFF] @property def name(self): @@ -68,7 +69,6 @@ class NestThermostat(ClimateDevice): return { "humidity": self.device.humidity, "target_humidity": self.device.target_humidity, - "mode": self.device.mode } @property @@ -79,12 +79,16 @@ class NestThermostat(ClimateDevice): @property def current_operation(self): """Return current operation ie. heat, cool, idle.""" - if self.device.hvac_ac_state: + if self.device.mode == 'cool': return STATE_COOL - elif self.device.hvac_heater_state: + elif self.device.mode == 'heat': return STATE_HEAT + elif self.device.mode == 'range': + return STATE_AUTO + elif self.device.mode == 'off': + return STATE_OFF else: - return STATE_IDLE + return STATE_UNKNOWN @property def target_temperature(self): @@ -139,7 +143,14 @@ class NestThermostat(ClimateDevice): def set_operation_mode(self, operation_mode): """Set operation mode.""" - self.device.mode = operation_mode + if operation_mode == STATE_HEAT: + self.device.mode = 'heat' + elif operation_mode == STATE_COOL: + self.device.mode = 'cool' + elif operation_mode == STATE_AUTO: + self.device.mode = 'range' + elif operation_mode == STATE_OFF: + self.device.mode = 'off' @property def operation_list(self): diff --git a/homeassistant/components/sensor/nest.py b/homeassistant/components/sensor/nest.py index 7a89265a8bd..13a97b7be04 100644 --- a/homeassistant/components/sensor/nest.py +++ b/homeassistant/components/sensor/nest.py @@ -16,7 +16,7 @@ from homeassistant.const import ( DEPENDENCIES = ['nest'] SENSOR_TYPES = ['humidity', - 'mode', + 'operation_mode', 'last_ip', 'local_ip', 'last_connection', From 5cb8ce71ef78015ef6c394684068dbac67d27f25 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 30 Sep 2016 00:14:08 -0700 Subject: [PATCH 3/4] Lint --- homeassistant/components/climate/nest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/climate/nest.py b/homeassistant/components/climate/nest.py index 2d3b95bb5cf..2884f4d2eb2 100644 --- a/homeassistant/components/climate/nest.py +++ b/homeassistant/components/climate/nest.py @@ -8,7 +8,7 @@ import logging import voluptuous as vol import homeassistant.components.nest as nest from homeassistant.components.climate import ( - STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_IDLE, ClimateDevice, + STATE_AUTO, STATE_COOL, STATE_HEAT, ClimateDevice, PLATFORM_SCHEMA, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, ATTR_TEMPERATURE) from homeassistant.const import ( From dfb92fa8362a65ee02b21621754652a176cdbff3 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 30 Sep 2016 00:15:14 -0700 Subject: [PATCH 4/4] Version bump to 0.29.5 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 62b91181bb8..b5869d2d3c0 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 29 -PATCH_VERSION = '4' +PATCH_VERSION = '5' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 4, 2)