From b367e87edc2ef6d7449679f2e47405a79a3fa627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Matheson=20Wergeland?= Date: Sat, 7 Nov 2026 14:46:03 +0100 Subject: [PATCH] Show the configured-unit temperature and range in the climate out-of-range (#190955) --- homeassistant/components/climate/services.py | 19 +++++++++++++------ tests/components/climate/test_init.py | 10 ++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/climate/services.py b/homeassistant/components/climate/services.py index 46d031ece79e..0a97071932e6 100644 --- a/homeassistant/components/climate/services.py +++ b/homeassistant/components/climate/services.py @@ -144,15 +144,22 @@ async def _async_service_temperature_set( ) _LOGGER.debug( - "Check valid temperature %d %s (%d %s) in range %d %s - %d %s", + ( + "Check valid temperature %g %s in range %g %s - %g %s" + " (%g %s in range %g %s - %g %s)" + ), check_temp, temp_unit, - temp, - hass.config.units.temperature_unit, min_temp, temp_unit, max_temp, temp_unit, + temp, + hass.config.units.temperature_unit, + shown_min_temp, + hass.config.units.temperature_unit, + shown_max_temp, + hass.config.units.temperature_unit, ) if (check_temp < min_temp and temp < shown_min_temp) or ( check_temp > max_temp and temp > shown_max_temp @@ -161,9 +168,9 @@ async def _async_service_temperature_set( translation_domain=DOMAIN, translation_key="temp_out_of_range", translation_placeholders={ - "check_temp": str(check_temp), - "min_temp": str(min_temp), - "max_temp": str(max_temp), + "check_temp": str(temp), + "min_temp": str(shown_min_temp), + "max_temp": str(shown_max_temp), }, ) kwargs[value] = min(max(check_temp, min_temp), max_temp) diff --git a/tests/components/climate/test_init.py b/tests/components/climate/test_init.py index 68dd5cc66cf8..d587c0cbb6f2 100644 --- a/tests/components/climate/test_init.py +++ b/tests/components/climate/test_init.py @@ -777,6 +777,11 @@ async def test_temperature_validation_display_rounding( blocking=True, ) assert exc.value.translation_key == "temp_out_of_range" + assert exc.value.translation_placeholders == { + "check_temp": str(temperature), + "min_temp": "16", + "max_temp": "32", + } assert test_climate.native_target_temperature == 89.5 # 62 °F is 16.7 °C, shown as 17 °C. Temperatures between the native and the @@ -804,6 +809,11 @@ async def test_temperature_validation_display_rounding( blocking=True, ) assert exc.value.translation_key == "temp_out_of_range" + assert exc.value.translation_placeholders == { + "check_temp": "16.5", + "min_temp": "17", + "max_temp": "32", + } async def test_target_temp_high_higher_than_low(