mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Fix temp conversion for nest setpoint (#3373)
* Fix temp conversion for nest setpoint * DEbug
This commit is contained in:
parent
8ba952ee0e
commit
efbc378226
@ -4,15 +4,17 @@ Support for Nest thermostats.
|
|||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/climate.nest/
|
https://home-assistant.io/components/climate.nest/
|
||||||
"""
|
"""
|
||||||
|
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_COOL, STATE_HEAT, STATE_IDLE, ClimateDevice, PLATFORM_SCHEMA)
|
STATE_COOL, STATE_HEAT, STATE_IDLE, ClimateDevice, PLATFORM_SCHEMA)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
TEMP_CELSIUS, CONF_SCAN_INTERVAL, ATTR_TEMPERATURE)
|
TEMP_CELSIUS, CONF_SCAN_INTERVAL, ATTR_TEMPERATURE)
|
||||||
|
from homeassistant.util.temperature import convert as convert_temperature
|
||||||
|
|
||||||
DEPENDENCIES = ['nest']
|
DEPENDENCIES = ['nest']
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_SCAN_INTERVAL):
|
vol.Optional(CONF_SCAN_INTERVAL):
|
||||||
@ -22,7 +24,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the Nest thermostat."""
|
"""Setup the Nest thermostat."""
|
||||||
add_devices([NestThermostat(structure, device)
|
temp_unit = hass.config.units.temperature_unit
|
||||||
|
add_devices([NestThermostat(structure, device, temp_unit)
|
||||||
for structure, device in nest.devices()])
|
for structure, device in nest.devices()])
|
||||||
|
|
||||||
|
|
||||||
@ -30,8 +33,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
class NestThermostat(ClimateDevice):
|
class NestThermostat(ClimateDevice):
|
||||||
"""Representation of a Nest thermostat."""
|
"""Representation of a Nest thermostat."""
|
||||||
|
|
||||||
def __init__(self, structure, device):
|
def __init__(self, structure, device, temp_unit):
|
||||||
"""Initialize the thermostat."""
|
"""Initialize the thermostat."""
|
||||||
|
self._unit = temp_unit
|
||||||
self.structure = structure
|
self.structure = structure
|
||||||
self.device = device
|
self.device = device
|
||||||
|
|
||||||
@ -134,7 +138,9 @@ class NestThermostat(ClimateDevice):
|
|||||||
|
|
||||||
def set_temperature(self, **kwargs):
|
def set_temperature(self, **kwargs):
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
temperature = kwargs.get(ATTR_TEMPERATURE)
|
temperature = convert_temperature(kwargs.get(ATTR_TEMPERATURE),
|
||||||
|
self._unit, TEMP_CELSIUS)
|
||||||
|
_LOGGER.debug("Nest set_temperature-input-value=%s", temperature)
|
||||||
if temperature is None:
|
if temperature is None:
|
||||||
return
|
return
|
||||||
if self.device.mode == 'range':
|
if self.device.mode == 'range':
|
||||||
@ -142,6 +148,7 @@ class NestThermostat(ClimateDevice):
|
|||||||
temperature = (temperature, self.target_temperature_high)
|
temperature = (temperature, self.target_temperature_high)
|
||||||
elif self.target_temperature == self.target_temperature_high:
|
elif self.target_temperature == self.target_temperature_high:
|
||||||
temperature = (self.target_temperature_low, temperature)
|
temperature = (self.target_temperature_low, temperature)
|
||||||
|
_LOGGER.debug("Nest set_temperature-output-value=%s", temperature)
|
||||||
self.device.target = temperature
|
self.device.target = temperature
|
||||||
|
|
||||||
def set_operation_mode(self, operation_mode):
|
def set_operation_mode(self, operation_mode):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user