mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 00:27:19 +00:00
commit
d76cf092c3
@ -8,10 +8,11 @@ import logging
|
|||||||
import voluptuous as vol
|
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, 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, 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']
|
||||||
@ -30,7 +31,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
for structure, device in nest.devices()])
|
for structure, device in nest.devices()])
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=abstract-method
|
# pylint: disable=abstract-method,too-many-public-methods
|
||||||
class NestThermostat(ClimateDevice):
|
class NestThermostat(ClimateDevice):
|
||||||
"""Representation of a Nest thermostat."""
|
"""Representation of a Nest thermostat."""
|
||||||
|
|
||||||
@ -40,6 +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_HEAT, STATE_COOL, STATE_AUTO,
|
||||||
|
STATE_OFF]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -57,10 +60,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):
|
||||||
@ -69,7 +69,6 @@ class NestThermostat(ClimateDevice):
|
|||||||
return {
|
return {
|
||||||
"humidity": self.device.humidity,
|
"humidity": self.device.humidity,
|
||||||
"target_humidity": self.device.target_humidity,
|
"target_humidity": self.device.target_humidity,
|
||||||
"mode": self.device.mode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -78,14 +77,26 @@ 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.mode == 'cool':
|
||||||
return STATE_COOL
|
return STATE_COOL
|
||||||
elif self.device.hvac_heater_state is True:
|
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
|
||||||
|
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):
|
||||||
@ -95,7 +106,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 +117,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,13 +134,28 @@ 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
|
||||||
|
|
||||||
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
|
||||||
|
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."""
|
||||||
|
@ -16,7 +16,7 @@ from homeassistant.const import (
|
|||||||
|
|
||||||
DEPENDENCIES = ['nest']
|
DEPENDENCIES = ['nest']
|
||||||
SENSOR_TYPES = ['humidity',
|
SENSOR_TYPES = ['humidity',
|
||||||
'mode',
|
'operation_mode',
|
||||||
'last_ip',
|
'last_ip',
|
||||||
'local_ip',
|
'local_ip',
|
||||||
'last_connection',
|
'last_connection',
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"""Constants used by Home Assistant components."""
|
"""Constants used by Home Assistant components."""
|
||||||
MAJOR_VERSION = 0
|
MAJOR_VERSION = 0
|
||||||
MINOR_VERSION = 29
|
MINOR_VERSION = 29
|
||||||
PATCH_VERSION = '4'
|
PATCH_VERSION = '5'
|
||||||
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
||||||
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
||||||
REQUIRED_PYTHON_VER = (3, 4, 2)
|
REQUIRED_PYTHON_VER = (3, 4, 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user