hass-core/homeassistant/helpers/temperature.py

20 lines
555 B
Python
Raw Normal View History

2015-08-16 22:06:01 -07:00
"""
homeassistant.helpers.temperature
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Methods to help handle temperature in Home Assistant.
"""
from homeassistant.const import TEMP_CELCIUS
import homeassistant.util.temperature as temp_util
def convert(temperature, unit, to_unit):
""" Converts temperature to correct unit. """
2015-10-22 22:04:37 -07:00
if unit == to_unit or unit is None or to_unit is None:
2015-08-16 22:06:01 -07:00
return temperature
elif unit == TEMP_CELCIUS:
return temp_util.celcius_to_fahrenheit(temperature)
return temp_util.fahrenheit_to_celcius(temperature)