hass-core/homeassistant/util/temperature.py

30 lines
902 B
Python
Raw Normal View History

2016-03-07 23:20:48 +01:00
"""Temperature util functions."""
2015-08-16 21:36:33 -07:00
2016-04-19 20:30:44 -07:00
import logging
2015-08-16 21:36:33 -07:00
2015-08-16 22:06:01 -07:00
def fahrenheit_to_celcius(fahrenheit):
2016-04-19 20:30:44 -07:00
"""**DEPRECATED** Convert a Fahrenheit temperature to Celsius."""
logging.getLogger(__name__).warning(
'fahrenheit_to_celcius is now fahrenheit_to_celsius '
'correcting a spelling mistake')
return fahrenheit_to_celsius(fahrenheit)
def fahrenheit_to_celsius(fahrenheit):
2016-03-07 23:20:48 +01:00
"""Convert a Fahrenheit temperature to Celsius."""
2015-08-16 21:36:33 -07:00
return (fahrenheit - 32.0) / 1.8
2015-08-16 22:06:01 -07:00
def celcius_to_fahrenheit(celcius):
2016-04-19 20:30:44 -07:00
"""**DEPRECATED** Convert a Celsius temperature to Fahrenheit."""
logging.getLogger(__name__).warning(
'celcius_to_fahrenheit is now celsius_to_fahrenheit correcting '
'a spelling mistake')
return celsius_to_fahrenheit(celcius)
def celsius_to_fahrenheit(celsius):
2016-03-07 23:20:48 +01:00
"""Convert a Celsius temperature to Fahrenheit."""
2016-04-19 20:30:44 -07:00
return celsius * 1.8 + 32.0