Add temp convert to climate base object (#3611)

* Add temp convert to climate base object

* fix nest

* fix lint
This commit is contained in:
Pascal Vizeli 2016-10-02 07:15:19 +02:00 committed by Paulus Schoutsen
parent 9683e3e3ad
commit c189c05676
2 changed files with 13 additions and 10 deletions

View File

@ -235,10 +235,17 @@ def setup(hass, config):
def temperature_set_service(service):
"""Set temperature on the target climate devices."""
target_climate = component.extract_from_service(service)
kwargs = service.data
for climate in target_climate:
climate.set_temperature(**kwargs)
for climate in target_climate:
kwargs = {}
for value, temp in service.data.items():
kwargs[value] = convert_temperature(
temp,
hass.config.units.temperature_unit,
climate.unit_of_measurement
)
climate.set_temperature(**kwargs)
if climate.should_poll:
climate.update_ha_state(True)

View File

@ -13,7 +13,6 @@ from homeassistant.components.climate import (
ATTR_TEMPERATURE)
from homeassistant.const import (
TEMP_CELSIUS, CONF_SCAN_INTERVAL, STATE_ON, STATE_OFF, STATE_UNKNOWN)
from homeassistant.util.temperature import convert as convert_temperature
DEPENDENCIES = ['nest']
_LOGGER = logging.getLogger(__name__)
@ -127,12 +126,9 @@ class NestThermostat(ClimateDevice):
def set_temperature(self, **kwargs):
"""Set new target temperature."""
if kwargs.get(ATTR_TARGET_TEMP_LOW) is not None and \
kwargs.get(ATTR_TARGET_TEMP_HIGH) is not None:
target_temp_high = convert_temperature(kwargs.get(
ATTR_TARGET_TEMP_HIGH), self._unit, TEMP_CELSIUS)
target_temp_low = convert_temperature(kwargs.get(
ATTR_TARGET_TEMP_LOW), self._unit, TEMP_CELSIUS)
target_temp_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
target_temp_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
if target_temp_low is not None and target_temp_high is not None:
if self.device.mode == 'range':
temp = (target_temp_low, target_temp_high)