Skip to content

Commit

Permalink
Fixed issue home-assistant#3574 - Temperature slider fixed on fronten…
Browse files Browse the repository at this point in the history
…d on heat/cool mode
  • Loading branch information
tchellomello committed Sep 30, 2016
1 parent c000e74 commit 443c390
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions homeassistant/components/climate/nest.py
Expand Up @@ -9,9 +9,10 @@
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']
Expand Down Expand Up @@ -40,6 +41,7 @@ def __init__(self, structure, device, temp_unit):
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):
Expand All @@ -57,10 +59,7 @@ def name(self):
@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):
Expand All @@ -78,15 +77,23 @@ def current_temperature(self):
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':
return self.device.target
else:
return None

@property
def target_temperature_low(self):
"""Return the lower bound temperature we try to reach."""
Expand All @@ -95,7 +102,8 @@ def target_temperature_low(self):
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):
Expand All @@ -105,7 +113,8 @@ def target_temperature_high(self):
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):
Expand All @@ -121,14 +130,22 @@ def set_temperature(self, **kwargs):
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

def set_operation_mode(self, operation_mode):
"""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
Expand Down

0 comments on commit 443c390

Please sign in to comment.