mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Small cleanups to temperature helper (#107625)
This commit is contained in:
parent
9ca09bd6f0
commit
49e3c740cc
@ -24,17 +24,14 @@ def display_temp(
|
|||||||
raise TypeError(f"Temperature is not a number: {temperature}")
|
raise TypeError(f"Temperature is not a number: {temperature}")
|
||||||
|
|
||||||
if temperature_unit != ha_unit:
|
if temperature_unit != ha_unit:
|
||||||
temperature = TemperatureConverter.convert(
|
temperature = TemperatureConverter.converter_factory(temperature_unit, ha_unit)(
|
||||||
temperature, temperature_unit, ha_unit
|
temperature
|
||||||
)
|
)
|
||||||
|
|
||||||
# Round in the units appropriate
|
# Round in the units appropriate
|
||||||
if precision == PRECISION_HALVES:
|
if precision == PRECISION_HALVES:
|
||||||
temperature = round(temperature * 2) / 2.0
|
return round(temperature * 2) / 2.0
|
||||||
elif precision == PRECISION_TENTHS:
|
if precision == PRECISION_TENTHS:
|
||||||
temperature = round(temperature, 1)
|
return round(temperature, 1)
|
||||||
# Integer as a fall back (PRECISION_WHOLE)
|
# Integer as a fall back (PRECISION_WHOLE)
|
||||||
else:
|
return round(temperature)
|
||||||
temperature = round(temperature)
|
|
||||||
|
|
||||||
return temperature
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user