Skip to content

Commit

Permalink
Don't round values in Thermostat internal state (home-assistant#1782)
Browse files Browse the repository at this point in the history
Since all values coming out of the Thermostat component pass though the
_convert_for_display() method (which handles any necessary rounding),
there is no need to round values that only exist in the internal state
of the thermostat device. It serves no purpose and risks rounding
errors/precision loss.
  • Loading branch information
JshWright authored and balloob committed Apr 10, 2016
1 parent 3d98b8b commit 24257fe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/thermostat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ def turn_fan_off(self):
@property
def min_temp(self):
"""Return the minimum temperature."""
return round(convert(7, TEMP_CELCIUS, self.unit_of_measurement))
return convert(7, TEMP_CELCIUS, self.unit_of_measurement)

@property
def max_temp(self):
"""Return the maximum temperature."""
return round(convert(35, TEMP_CELCIUS, self.unit_of_measurement))
return convert(35, TEMP_CELCIUS, self.unit_of_measurement)

def _convert_for_display(self, temp):
"""Convert temperature into preferred units for display purposes."""
Expand Down
12 changes: 6 additions & 6 deletions homeassistant/components/thermostat/nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def device_state_attributes(self):
@property
def current_temperature(self):
"""Return the current temperature."""
return round(self.device.temperature, 1)
return self.device.temperature

@property
def operation(self):
Expand Down Expand Up @@ -102,21 +102,21 @@ def target_temperature(self):
else:
temp = target

return round(temp, 1)
return temp

@property
def target_temperature_low(self):
"""Return the lower bound temperature we try to reach."""
if self.device.mode == 'range':
return round(self.device.target[0], 1)
return round(self.target_temperature, 1)
return self.device.target[0]
return self.target_temperature

@property
def target_temperature_high(self):
"""Return the upper bound temperature we try to reach."""
if self.device.mode == 'range':
return round(self.device.target[1], 1)
return round(self.target_temperature, 1)
return self.device.target[1]
return self.target_temperature

@property
def is_away_mode_on(self):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/thermostat/radiotherm.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def device_state_attributes(self):
@property
def current_temperature(self):
"""Return the current temperature."""
return round(self._current_temperature, 1)
return self._current_temperature

@property
def operation(self):
Expand All @@ -90,7 +90,7 @@ def operation(self):
@property
def target_temperature(self):
"""Return the temperature we try to reach."""
return round(self._target_temperature, 1)
return self._target_temperature

def update(self):
"""Update the data from the thermostat."""
Expand Down

0 comments on commit 24257fe

Please sign in to comment.