parent
6f6b16b410
commit
9925a19a75
2 changed files with 10 additions and 10 deletions
|
@ -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…
Add table
Reference in a new issue