Skip to content
Snippets Groups Projects
Commit efbc3782 authored by John Arild Berentsen's avatar John Arild Berentsen Committed by GitHub
Browse files

Fix temp conversion for nest setpoint (#3373)

* Fix temp conversion for nest setpoint

* DEbug
parent 8ba952ee
No related branches found
No related tags found
No related merge requests found
...@@ -4,15 +4,17 @@ Support for Nest thermostats. ...@@ -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({ ...@@ -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): ...@@ -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): ...@@ -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): ...@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment