Compare commits
No commits in common. "39cd852b36b7408c386e15068d3c10c30c703495" and "466d41f1bb9c527662623198fe62008c4ce342f9" have entirely different histories.
39cd852b36
...
466d41f1bb
|
|
@ -218,22 +218,15 @@ def celsius_to_fahrenheit(celsius: float) -> float:
|
||||||
return celsius * 9.0 / 5.0 + 32
|
return celsius * 9.0 / 5.0 + 32
|
||||||
|
|
||||||
|
|
||||||
def heat_index(data: Any, convert: bool = False) -> float | None:
|
def heat_index(data: Any, convert: bool = False) -> float:
|
||||||
"""Calculate heat index from temperature.
|
"""Calculate heat index from temperature.
|
||||||
|
|
||||||
data: dict with temperature and humidity
|
data: dict with temperature and humidity
|
||||||
convert: bool, convert recieved data from Celsius to Fahrenheit
|
convert: bool, convert recieved data from Celsius to Fahrenheit
|
||||||
"""
|
"""
|
||||||
|
|
||||||
temp = data.get(OUTSIDE_TEMP, None)
|
temp = float(data[OUTSIDE_TEMP])
|
||||||
rh = data.get(OUTSIDE_HUMIDITY, None)
|
rh = float(data[OUTSIDE_HUMIDITY])
|
||||||
|
|
||||||
if not temp or not rh:
|
|
||||||
return None
|
|
||||||
|
|
||||||
temp = float(temp)
|
|
||||||
rh = float(rh)
|
|
||||||
|
|
||||||
adjustment = None
|
adjustment = None
|
||||||
|
|
||||||
if convert:
|
if convert:
|
||||||
|
|
@ -263,21 +256,15 @@ def heat_index(data: Any, convert: bool = False) -> float | None:
|
||||||
return simple
|
return simple
|
||||||
|
|
||||||
|
|
||||||
def chill_index(data: Any, convert: bool = False) -> float | None:
|
def chill_index(data: Any, convert: bool = False) -> float:
|
||||||
"""Calculate wind chill index from temperature and wind speed.
|
"""Calculate wind chill index from temperature and wind speed.
|
||||||
|
|
||||||
data: dict with temperature and wind speed
|
data: dict with temperature and wind speed
|
||||||
convert: bool, convert recieved data from Celsius to Fahrenheit
|
convert: bool, convert recieved data from Celsius to Fahrenheit
|
||||||
"""
|
"""
|
||||||
|
|
||||||
temp = data.get(OUTSIDE_TEMP, None)
|
temp = float(data[OUTSIDE_TEMP])
|
||||||
wind = data.get(WIND_SPEED, None)
|
wind = float(data[WIND_SPEED])
|
||||||
|
|
||||||
if not temp or not wind:
|
|
||||||
return None
|
|
||||||
|
|
||||||
temp = float(temp)
|
|
||||||
wind = float(wind)
|
|
||||||
|
|
||||||
if convert:
|
if convert:
|
||||||
temp = celsius_to_fahrenheit(temp)
|
temp = celsius_to_fahrenheit(temp)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue