From 8c9d1d9af1a474b6a664da78d81a05649d7a0b45 Mon Sep 17 00:00:00 2001 From: Ferry van Zeelst Date: Tue, 11 Oct 2016 08:57:14 +0200 Subject: [PATCH] Added additional checks which hides functions which are not supported by Nest (#3751) * Added additional checks which hides functions which are not support (like fans / humidity / cooling) * Fixed pylint and flake8 errors (not test file available) * Fixed pydocstyle error * Refactored Code and Comments as described in pull-request * Added additional comment and requesting retest * Upgraded to python-nest 2.11 which contains previously hidden functions --- homeassistant/components/climate/nest.py | 36 ++++++++++++++++++------ homeassistant/components/nest.py | 2 +- requirements_all.txt | 2 +- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/climate/nest.py b/homeassistant/components/climate/nest.py index 36be2ca25f5..c4582b839f3 100644 --- a/homeassistant/components/climate/nest.py +++ b/homeassistant/components/climate/nest.py @@ -40,8 +40,19 @@ class NestThermostat(ClimateDevice): self.structure = structure self.device = device self._fan_list = [STATE_ON, STATE_AUTO] - self._operation_list = [STATE_HEAT, STATE_COOL, STATE_AUTO, - STATE_OFF] + + # Not all nest devices support cooling and heating remove unused + self._operation_list = [STATE_OFF] + + # Add supported nest thermostat features + if self.device.can_heat: + self._operation_list.append(STATE_HEAT) + + if self.device.can_cool: + self._operation_list.append(STATE_COOL) + + if self.device.can_heat and self.device.can_cool: + self._operation_list.append(STATE_AUTO) @property def name(self): @@ -64,11 +75,15 @@ class NestThermostat(ClimateDevice): @property def device_state_attributes(self): """Return the device specific state attributes.""" - # Move these to Thermostat Device and make them global - return { - "humidity": self.device.humidity, - "target_humidity": self.device.target_humidity, - } + if self.device.has_humidifier or self.device.has_dehumidifier: + # Move these to Thermostat Device and make them global + return { + "humidity": self.device.humidity, + "target_humidity": self.device.target_humidity, + } + else: + # No way to control humidity not show setting + return {} @property def current_temperature(self): @@ -164,7 +179,12 @@ class NestThermostat(ClimateDevice): @property def current_fan_mode(self): """Return whether the fan is on.""" - return STATE_ON if self.device.fan else STATE_AUTO + if self.device.has_fan: + # Return whether the fan is on + return STATE_ON if self.device.fan else STATE_AUTO + else: + # No Fan available so disable slider + return None @property def fan_list(self): diff --git a/homeassistant/components/nest.py b/homeassistant/components/nest.py index a3d86a725aa..b8aa1d1c70a 100644 --- a/homeassistant/components/nest.py +++ b/homeassistant/components/nest.py @@ -14,7 +14,7 @@ from homeassistant.const import (CONF_PASSWORD, CONF_USERNAME, CONF_STRUCTURE) _LOGGER = logging.getLogger(__name__) -REQUIREMENTS = ['python-nest==2.10.0'] +REQUIREMENTS = ['python-nest==2.11.0'] DOMAIN = 'nest' diff --git a/requirements_all.txt b/requirements_all.txt index 52c63ad8607..980fb226d7b 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -389,7 +389,7 @@ python-mpd2==0.5.5 python-mystrom==0.3.6 # homeassistant.components.nest -python-nest==2.10.0 +python-nest==2.11.0 # homeassistant.components.device_tracker.nmap_tracker python-nmap==0.6.1