mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
* 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
This commit is contained in:
parent
7ac8425099
commit
9ea030f42e
@ -9,9 +9,10 @@ import voluptuous as vol
|
|||||||
import homeassistant.components.nest as nest
|
import homeassistant.components.nest as nest
|
||||||
from homeassistant.components.climate import (
|
from homeassistant.components.climate import (
|
||||||
STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_IDLE, ClimateDevice,
|
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 (
|
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
|
from homeassistant.util.temperature import convert as convert_temperature
|
||||||
|
|
||||||
DEPENDENCIES = ['nest']
|
DEPENDENCIES = ['nest']
|
||||||
@ -40,6 +41,7 @@ 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]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -57,10 +59,7 @@ class NestThermostat(ClimateDevice):
|
|||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit of measurement."""
|
"""Return the unit of measurement."""
|
||||||
if self.device.measurement_scale == 'F':
|
return TEMP_CELSIUS
|
||||||
return TEMP_FAHRENHEIT
|
|
||||||
elif self.device.measurement_scale == 'C':
|
|
||||||
return TEMP_CELSIUS
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
@ -78,15 +77,23 @@ class NestThermostat(ClimateDevice):
|
|||||||
return self.device.temperature
|
return self.device.temperature
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def 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 is True:
|
if self.device.hvac_ac_state:
|
||||||
return STATE_COOL
|
return STATE_COOL
|
||||||
elif self.device.hvac_heater_state is True:
|
elif self.device.hvac_heater_state:
|
||||||
return STATE_HEAT
|
return STATE_HEAT
|
||||||
else:
|
else:
|
||||||
return STATE_IDLE
|
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
|
@property
|
||||||
def target_temperature_low(self):
|
def target_temperature_low(self):
|
||||||
"""Return the lower bound temperature we try to reach."""
|
"""Return the lower bound temperature we try to reach."""
|
||||||
@ -95,7 +102,8 @@ class NestThermostat(ClimateDevice):
|
|||||||
return self.device.away_temperature[0]
|
return self.device.away_temperature[0]
|
||||||
if self.device.mode == 'range':
|
if self.device.mode == 'range':
|
||||||
return self.device.target[0]
|
return self.device.target[0]
|
||||||
return self.target_temperature
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_high(self):
|
def target_temperature_high(self):
|
||||||
@ -105,7 +113,8 @@ class NestThermostat(ClimateDevice):
|
|||||||
return self.device.away_temperature[1]
|
return self.device.away_temperature[1]
|
||||||
if self.device.mode == 'range':
|
if self.device.mode == 'range':
|
||||||
return self.device.target[1]
|
return self.device.target[1]
|
||||||
return self.target_temperature
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_away_mode_on(self):
|
def is_away_mode_on(self):
|
||||||
@ -121,7 +130,10 @@ class NestThermostat(ClimateDevice):
|
|||||||
target_temp_low = convert_temperature(kwargs.get(
|
target_temp_low = convert_temperature(kwargs.get(
|
||||||
ATTR_TARGET_TEMP_LOW), self._unit, TEMP_CELSIUS)
|
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)
|
_LOGGER.debug("Nest set_temperature-output-value=%s", temp)
|
||||||
self.device.target = temp
|
self.device.target = temp
|
||||||
|
|
||||||
@ -129,6 +141,11 @@ class NestThermostat(ClimateDevice):
|
|||||||
"""Set operation mode."""
|
"""Set operation mode."""
|
||||||
self.device.mode = 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):
|
def turn_away_mode_on(self):
|
||||||
"""Turn away on."""
|
"""Turn away on."""
|
||||||
self.structure.away = True
|
self.structure.away = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user