Add temperature util, helpers
This commit is contained in:
parent
b61b3c611d
commit
086961d109
3 changed files with 28 additions and 13 deletions
19
homeassistant/helpers/temperature.py
Normal file
19
homeassistant/helpers/temperature.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
"""
|
||||
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. """
|
||||
if unit == to_unit:
|
||||
return temperature
|
||||
elif unit == TEMP_CELCIUS:
|
||||
return temp_util.celcius_to_fahrenheit(temperature)
|
||||
|
||||
return temp_util.fahrenheit_to_celcius(temperature)
|
Loading…
Add table
Add a link
Reference in a new issue