mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add temperature util, helpers
This commit is contained in:
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)
|
||||
Reference in New Issue
Block a user