mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add temp convert to climate base object (#3611)
* Add temp convert to climate base object * fix nest * fix lint
This commit is contained in:
parent
9683e3e3ad
commit
c189c05676
@ -235,10 +235,17 @@ def setup(hass, config):
|
|||||||
def temperature_set_service(service):
|
def temperature_set_service(service):
|
||||||
"""Set temperature on the target climate devices."""
|
"""Set temperature on the target climate devices."""
|
||||||
target_climate = component.extract_from_service(service)
|
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:
|
if climate.should_poll:
|
||||||
climate.update_ha_state(True)
|
climate.update_ha_state(True)
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ from homeassistant.components.climate import (
|
|||||||
ATTR_TEMPERATURE)
|
ATTR_TEMPERATURE)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
TEMP_CELSIUS, CONF_SCAN_INTERVAL, STATE_ON, STATE_OFF, STATE_UNKNOWN)
|
TEMP_CELSIUS, CONF_SCAN_INTERVAL, STATE_ON, STATE_OFF, STATE_UNKNOWN)
|
||||||
from homeassistant.util.temperature import convert as convert_temperature
|
|
||||||
|
|
||||||
DEPENDENCIES = ['nest']
|
DEPENDENCIES = ['nest']
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -127,12 +126,9 @@ class NestThermostat(ClimateDevice):
|
|||||||
|
|
||||||
def set_temperature(self, **kwargs):
|
def set_temperature(self, **kwargs):
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
if kwargs.get(ATTR_TARGET_TEMP_LOW) is not None and \
|
target_temp_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
|
||||||
kwargs.get(ATTR_TARGET_TEMP_HIGH) is not None:
|
target_temp_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
|
||||||
target_temp_high = convert_temperature(kwargs.get(
|
if target_temp_low is not None and target_temp_high is not None:
|
||||||
ATTR_TARGET_TEMP_HIGH), self._unit, TEMP_CELSIUS)
|
|
||||||
target_temp_low = convert_temperature(kwargs.get(
|
|
||||||
ATTR_TARGET_TEMP_LOW), self._unit, TEMP_CELSIUS)
|
|
||||||
|
|
||||||
if self.device.mode == 'range':
|
if self.device.mode == 'range':
|
||||||
temp = (target_temp_low, target_temp_high)
|
temp = (target_temp_low, target_temp_high)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user