1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00
Files
core/homeassistant/helpers/temperature.py
2016-02-18 21:27:50 -08:00

20 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)