hass-core/homeassistant/helpers/temperature.py
2016-02-18 21:27:50 -08:00

19 lines
555 B
Python

"""
homeassistant.helpers.temperature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Methods to help handle temperature in Home Assistant.
"""
import homeassistant.util.temperature as temp_util
from homeassistant.const import TEMP_CELCIUS
def convert(temperature, unit, to_unit):
""" Converts temperature to correct unit. """
if unit == to_unit or unit is None or to_unit is None:
return temperature
elif unit == TEMP_CELCIUS:
return temp_util.celcius_to_fahrenheit(temperature)
return temp_util.fahrenheit_to_celcius(temperature)