diff --git a/homeassistant/components/daikin/climate.py b/homeassistant/components/daikin/climate.py index 3d064f47e97..fb708916039 100644 --- a/homeassistant/components/daikin/climate.py +++ b/homeassistant/components/daikin/climate.py @@ -118,8 +118,8 @@ async def async_setup_entry( 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.""" - return str(round(float(target_temperature), 1)).rstrip("0").rstrip(".") + """Format target temperature to be sent to the Daikin unit, rounding to nearest half degree.""" + return str(round(float(target_temperature) * 2, 0) / 2).rstrip("0").rstrip(".") class DaikinClimate(ClimateEntity): diff --git a/tests/components/daikin/test_temperature_format.py b/tests/components/daikin/test_temperature_format.py index d05efa98b8d..bc085fa1fd8 100644 --- a/tests/components/daikin/test_temperature_format.py +++ b/tests/components/daikin/test_temperature_format.py @@ -8,13 +8,13 @@ def test_int_conversion(): assert formatted == "16" -def test_decimal_conversion(): +def test_rounding(): """Check 1 decimal is kept when target temp is a decimal.""" formatted = format_target_temperature("16.1") - assert formatted == "16.1" - - -def test_decimal_conversion_more_digits(): - """Check at most 1 decimal is kept when target temp is a decimal with more than 1 decimal.""" - formatted = format_target_temperature("16.09") - assert formatted == "16.1" + assert formatted == "16" + formatted = format_target_temperature("16.3") + assert formatted == "16.5" + formatted = format_target_temperature("16.65") + assert formatted == "16.5" + formatted = format_target_temperature("16.9") + assert formatted == "17"