Add ability to change Nest mode to all available options

This commit is contained in:
Jeffery Wilson
2016-09-30 01:45:48 -04:00
parent 9ea030f42e
commit bf30674671

View File

@@ -12,7 +12,7 @@ from homeassistant.components.climate import (
PLATFORM_SCHEMA, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, PLATFORM_SCHEMA, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW,
ATTR_TEMPERATURE) ATTR_TEMPERATURE)
from homeassistant.const import ( 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 from homeassistant.util.temperature import convert as convert_temperature
DEPENDENCIES = ['nest'] DEPENDENCIES = ['nest']
@@ -41,7 +41,8 @@ class NestThermostat(ClimateDevice):
self.structure = structure self.structure = structure
self.device = device self.device = device
self._fan_list = [STATE_ON, STATE_AUTO] 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 @property
def name(self): def name(self):
@@ -79,12 +80,16 @@ class NestThermostat(ClimateDevice):
@property @property
def current_operation(self): def current_operation(self):
"""Return current operation ie. heat, cool, idle.""" """Return current operation ie. heat, cool, idle."""
if self.device.hvac_ac_state: if self.device.mode == 'cool':
return STATE_COOL return STATE_COOL
elif self.device.hvac_heater_state: elif self.device.mode == 'heat':
return STATE_HEAT return STATE_HEAT
elif self.device.mode == 'range':
return STATE_AUTO
elif self.device.mode == 'off':
return STATE_OFF
else: else:
return STATE_IDLE return STATE_UNKNOWN
@property @property
def target_temperature(self): def target_temperature(self):
@@ -139,7 +144,14 @@ class NestThermostat(ClimateDevice):
def set_operation_mode(self, operation_mode): def set_operation_mode(self, operation_mode):
"""Set 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 @property
def operation_list(self): def operation_list(self):