Skip to content

Commit

Permalink
Fix current_temperature is rounded (#6960)
Browse files Browse the repository at this point in the history
* Fix current_temperature is rounded

* fix  Unnecessary parens after 'if'
  • Loading branch information
aufano authored and balloob committed Apr 7, 2017
1 parent 51dc8b7 commit 2ce8c2f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions homeassistant/components/climate/__init__.py
Expand Up @@ -692,18 +692,16 @@ def max_humidity(self):

def _convert_for_display(self, temp):
"""Convert temperature into preferred units for display purposes."""
if (temp is None or not isinstance(temp, Number) or
self.temperature_unit == self.unit_of_measurement):
if temp is None or not isinstance(temp, Number):
return temp

value = convert_temperature(temp, self.temperature_unit,
self.unit_of_measurement)

if self.temperature_unit != self.unit_of_measurement:
temp = convert_temperature(temp, self.temperature_unit,
self.unit_of_measurement)
# Round in the units appropriate
if self.precision == PRECISION_HALVES:
return round(value * 2) / 2.0
return round(temp * 2) / 2.0
elif self.precision == PRECISION_TENTHS:
return round(value, 1)
return round(temp, 1)
else:
# PRECISION_WHOLE as a fall back
return round(value)
return round(temp)

0 comments on commit 2ce8c2f

Please sign in to comment.