diff --git a/homeassistant/components/climate/__init__.py b/homeassistant/components/climate/__init__.py index d35b142a8c44d323d3dde680734a4afba842e632..80ef97622d557f488246b628f761e88e5eba1a0c 100644 --- a/homeassistant/components/climate/__init__.py +++ b/homeassistant/components/climate/__init__.py @@ -58,6 +58,11 @@ ATTR_OPERATION_LIST = "operation_list" ATTR_SWING_MODE = "swing_mode" ATTR_SWING_LIST = "swing_list" +# The degree of precision for each platform +PRECISION_WHOLE = 1 +PRECISION_HALVES = 0.5 +PRECISION_TENTHS = 0.1 + CONVERTIBLE_ATTRIBUTE = [ ATTR_TEMPERATURE, ATTR_TARGET_TEMP_LOW, @@ -371,6 +376,14 @@ class ClimateDevice(Entity): else: return STATE_UNKNOWN + @property + def precision(self): + """Return the precision of the system.""" + if self.unit_of_measurement == TEMP_CELSIUS: + return PRECISION_TENTHS + else: + return PRECISION_WHOLE + @property def state_attributes(self): """Return the optional state attributes.""" @@ -569,8 +582,11 @@ class ClimateDevice(Entity): value = convert_temperature(temp, self.temperature_unit, self.unit_of_measurement) - if self.unit_of_measurement == TEMP_CELSIUS: + # Round in the units appropriate + if self.precision == PRECISION_HALVES: + return round(value * 2) / 2.0 + elif self.precision == PRECISION_TENTHS: return round(value, 1) else: - # Users of fahrenheit generally expect integer units. + # PRECISION_WHOLE as a fall back return round(value) diff --git a/homeassistant/components/climate/proliphix.py b/homeassistant/components/climate/proliphix.py index 5b3708db72e6ac3155cb91fb46ac3e94500f3f58..ef6553cc062c01c293e261e92843b8f790002738 100644 --- a/homeassistant/components/climate/proliphix.py +++ b/homeassistant/components/climate/proliphix.py @@ -7,7 +7,8 @@ https://home-assistant.io/components/climate.proliphix/ import voluptuous as vol from homeassistant.components.climate import ( - STATE_COOL, STATE_HEAT, STATE_IDLE, ClimateDevice, PLATFORM_SCHEMA) + PRECISION_TENTHS, STATE_COOL, STATE_HEAT, STATE_IDLE, + ClimateDevice, PLATFORM_SCHEMA) from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, CONF_USERNAME, TEMP_FAHRENHEIT, ATTR_TEMPERATURE) import homeassistant.helpers.config_validation as cv @@ -60,6 +61,15 @@ class ProliphixThermostat(ClimateDevice): """Return the name of the thermostat.""" return self._name + @property + def precision(self): + """Return the precision of the system. + + Proliphix temperature values are passed back and forth in the + API as tenths of degrees F (i.e. 690 for 69 degrees). + """ + return PRECISION_TENTHS + @property def device_state_attributes(self): """Return the device specific state attributes."""