mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
parent
022deb20fd
commit
e2bbdb26be
@ -118,8 +118,8 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
|
|
||||||
def format_target_temperature(target_temperature):
|
def format_target_temperature(target_temperature):
|
||||||
"""Format target temperature to be sent to the Daikin unit, taking care of keeping at most 1 decimal digit."""
|
"""Format target temperature to be sent to the Daikin unit, rounding to nearest half degree."""
|
||||||
return str(round(float(target_temperature), 1)).rstrip("0").rstrip(".")
|
return str(round(float(target_temperature) * 2, 0) / 2).rstrip("0").rstrip(".")
|
||||||
|
|
||||||
|
|
||||||
class DaikinClimate(ClimateEntity):
|
class DaikinClimate(ClimateEntity):
|
||||||
|
@ -8,13 +8,13 @@ def test_int_conversion():
|
|||||||
assert formatted == "16"
|
assert formatted == "16"
|
||||||
|
|
||||||
|
|
||||||
def test_decimal_conversion():
|
def test_rounding():
|
||||||
"""Check 1 decimal is kept when target temp is a decimal."""
|
"""Check 1 decimal is kept when target temp is a decimal."""
|
||||||
formatted = format_target_temperature("16.1")
|
formatted = format_target_temperature("16.1")
|
||||||
assert formatted == "16.1"
|
assert formatted == "16"
|
||||||
|
formatted = format_target_temperature("16.3")
|
||||||
|
assert formatted == "16.5"
|
||||||
def test_decimal_conversion_more_digits():
|
formatted = format_target_temperature("16.65")
|
||||||
"""Check at most 1 decimal is kept when target temp is a decimal with more than 1 decimal."""
|
assert formatted == "16.5"
|
||||||
formatted = format_target_temperature("16.09")
|
formatted = format_target_temperature("16.9")
|
||||||
assert formatted == "16.1"
|
assert formatted == "17"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user