2015-08-17 05:06:01 +00: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-23 05:04:37 +00:00
|
|
|
if unit == to_unit or unit is None or to_unit is None:
|
2015-08-17 05:06:01 +00:00
|
|
|
return temperature
|
|
|
|
elif unit == TEMP_CELCIUS:
|
|
|
|
return temp_util.celcius_to_fahrenheit(temperature)
|
|
|
|
|
|
|
|
return temp_util.fahrenheit_to_celcius(temperature)
|