From c4a71fbfa78a72e9d598e62cdcc6f3b6fb735c33 Mon Sep 17 00:00:00 2001 From: Josh Wright Date: Tue, 12 Apr 2016 18:15:24 -0400 Subject: [PATCH 1/5] Include away temps in target temps The target temperature methods were not taking the 'away' status into account. leading to misleading target temps being reported. --- homeassistant/components/thermostat/nest.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/thermostat/nest.py b/homeassistant/components/thermostat/nest.py index 9a52f58c1d9..2426e638c43 100644 --- a/homeassistant/components/thermostat/nest.py +++ b/homeassistant/components/thermostat/nest.py @@ -80,10 +80,9 @@ class NestThermostat(ThermostatDevice): @property def target_temperature(self): """Return the temperature we try to reach.""" - target = self.device.target - if self.device.mode == 'range': - low, high = target + low, high = self.target_temperature_low, \ + self.target_temperature_high if self.operation == STATE_COOL: temp = high elif self.operation == STATE_HEAT: @@ -95,13 +94,22 @@ class NestThermostat(ThermostatDevice): elif self.current_temperature >= range_average: temp = high else: - temp = target + if self.is_away_mode_on: + # away_temperature is a low, high tuple. Only one should be set + # if not in range mode, the other will be None + temp = self.device.away_temperature[0] or \ + self.device.away_temperature[1] + else: + temp = self.device.target return temp @property def target_temperature_low(self): """Return the lower bound temperature we try to reach.""" + if self.is_away_mode_on and self.device.away_temperature[0]: + # away_temperature is always a low, high tuple + return self.device.away_temperature[0] if self.device.mode == 'range': return self.device.target[0] return self.target_temperature @@ -109,6 +117,9 @@ class NestThermostat(ThermostatDevice): @property def target_temperature_high(self): """Return the upper bound temperature we try to reach.""" + if self.is_away_mode_on and self.device.away_temperature[1]: + # away_temperature is always a low, high tuple + return self.device.away_temperature[1] if self.device.mode == 'range': return self.device.target[1] return self.target_temperature From 942d722dcf8e2ccd5fef0775f689ac87b7926e81 Mon Sep 17 00:00:00 2001 From: Josh Wright Date: Tue, 12 Apr 2016 18:25:24 -0400 Subject: [PATCH 2/5] Improve target temperature selection logic When picking which of the high/low temperatures to display as the "target", it makes more sense to take the outside temperature into consideration, rather than the current temperature of the thermostat. If the temperature outside is less than the temperature of the thermostat, then we are far more likely to end up in "heating" mode eventually, and vice versa, regardless of where the current inside temp falls in the range between high and low. --- homeassistant/components/thermostat/nest.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/thermostat/nest.py b/homeassistant/components/thermostat/nest.py index 2426e638c43..7f78b4b2238 100644 --- a/homeassistant/components/thermostat/nest.py +++ b/homeassistant/components/thermostat/nest.py @@ -88,8 +88,10 @@ class NestThermostat(ThermostatDevice): elif self.operation == STATE_HEAT: temp = low else: - range_average = (low + high)/2 - if self.current_temperature < range_average: + # If the outside temp is lower than the current temp, consider + # the 'low' temp to the target, otherwise use the high temp + if (self.device.structure.weather.current.temperature < + self.current_temperature): temp = low elif self.current_temperature >= range_average: temp = high From 1685bbe1f7b39682d0b526ce4dd199c1f49a9054 Mon Sep 17 00:00:00 2001 From: Josh Wright Date: Tue, 12 Apr 2016 18:45:57 -0400 Subject: [PATCH 3/5] Fix copy/paste logic error --- homeassistant/components/thermostat/nest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/thermostat/nest.py b/homeassistant/components/thermostat/nest.py index 7f78b4b2238..63892238f58 100644 --- a/homeassistant/components/thermostat/nest.py +++ b/homeassistant/components/thermostat/nest.py @@ -93,7 +93,7 @@ class NestThermostat(ThermostatDevice): if (self.device.structure.weather.current.temperature < self.current_temperature): temp = low - elif self.current_temperature >= range_average: + else: temp = high else: if self.is_away_mode_on: From 4aa43bbf7aca57056878d29387986dd61ca4afe4 Mon Sep 17 00:00:00 2001 From: Jan Harkes Date: Tue, 12 Apr 2016 14:43:04 -0400 Subject: [PATCH 4/5] New version of betamax breaks the yr.no sensor test. Pin to betamax-0.5.1 for now. --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 162a4d89ee5..ebe359e7b54 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -4,5 +4,5 @@ coveralls>=1.1 pytest>=2.8.0 pytest-cov>=2.2.0 pytest-timeout>=1.0.0 -betamax>=0.5.1 +betamax==0.5.1 pydocstyle>=1.0.0 From 0e10f7ced903dfe193c9810d16f9792475a95d28 Mon Sep 17 00:00:00 2001 From: Jan Harkes Date: Tue, 12 Apr 2016 14:56:14 -0400 Subject: [PATCH 5/5] Ignore tests/config/deps/ for both git and flake8. Sometimes py.test leave some packages around in tests/config/deps. Make sure these do not accidentally get pulled into a commit or cause a local tox run to fail. --- .gitignore | 1 + setup.cfg | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e7d64517e17..5a3fa9649c0 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ config/custom_components/* !config/custom_components/hello_world.py !config/custom_components/mqtt_example.py +tests/config/deps tests/config/home-assistant.log # Hide sublime text stuff diff --git a/setup.cfg b/setup.cfg index a9a21de8388..2333efe6e70 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,4 +5,4 @@ universal = 1 testpaths = tests [flake8] -exclude = .venv,.git,.tox,docs,www_static,venv,bin,lib +exclude = .venv,.git,.tox,docs,www_static,venv,bin,lib,deps