From d259e4512b5593c1d56aae7dd9b7e137004f6e45 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Thu, 12 Sep 2024 21:41:00 +0200 Subject: [PATCH] Improve logging message for validation in climate (#125837) --- homeassistant/components/climate/__init__.py | 14 +++++++++++--- tests/components/climate/test_init.py | 11 ++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/climate/__init__.py b/homeassistant/components/climate/__init__.py index b0a9c5a4c5a..e6c1781a59f 100644 --- a/homeassistant/components/climate/__init__.py +++ b/homeassistant/components/climate/__init__.py @@ -713,7 +713,7 @@ class ClimateEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): ( "%s::%s sets the hvac_mode %s which is not " "valid for this entity with modes: %s. " - "This will stop working in 2025.3 and raise an error instead. " + "This will stop working in 2025.4 and raise an error instead. " "Please %s" ), self.platform.platform_name, @@ -937,6 +937,8 @@ async def async_service_temperature_set( ATTR_TEMPERATURE in service_call.data and not entity.supported_features & ClimateEntityFeature.TARGET_TEMPERATURE ): + # Warning implemented in 2024.10 and will be changed to raising + # a ServiceValidationError in 2025.4 report_issue = async_suggest_report_issue( entity.hass, integration_domain=entity.platform.platform_name, @@ -945,7 +947,9 @@ async def async_service_temperature_set( _LOGGER.warning( ( "%s::%s set_temperature action was used with temperature but the entity does not " - "implement the ClimateEntityFeature.TARGET_TEMPERATURE feature. Please %s" + "implement the ClimateEntityFeature.TARGET_TEMPERATURE feature. " + "This will stop working in 2025.4 and raise an error instead. " + "Please %s" ), entity.platform.platform_name, entity.__class__.__name__, @@ -956,6 +960,8 @@ async def async_service_temperature_set( and not entity.supported_features & ClimateEntityFeature.TARGET_TEMPERATURE_RANGE ): + # Warning implemented in 2024.10 and will be changed to raising + # a ServiceValidationError in 2025.4 report_issue = async_suggest_report_issue( entity.hass, integration_domain=entity.platform.platform_name, @@ -964,7 +970,9 @@ async def async_service_temperature_set( _LOGGER.warning( ( "%s::%s set_temperature action was used with target_temp_low but the entity does not " - "implement the ClimateEntityFeature.TARGET_TEMPERATURE_RANGE feature. Please %s" + "implement the ClimateEntityFeature.TARGET_TEMPERATURE_RANGE feature. " + "This will stop working in 2025.4 and raise an error instead. " + "Please %s" ), entity.platform.platform_name, entity.__class__.__name__, diff --git a/tests/components/climate/test_init.py b/tests/components/climate/test_init.py index b3f26dc775f..b0322e9ddd8 100644 --- a/tests/components/climate/test_init.py +++ b/tests/components/climate/test_init.py @@ -300,7 +300,9 @@ async def test_temperature_features_is_valid( assert ( "MockClimateTempEntity set_temperature action was used " "with temperature but the entity does not " - "implement the ClimateEntityFeature.TARGET_TEMPERATURE feature. Please" + "implement the ClimateEntityFeature.TARGET_TEMPERATURE feature. " + "This will stop working in 2025.4 and raise an error instead. " + "Please" ) in caplog.text await hass.services.async_call( @@ -316,7 +318,9 @@ async def test_temperature_features_is_valid( assert ( "MockClimateTempRangeEntity set_temperature action was used with " "target_temp_low but the entity does not " - "implement the ClimateEntityFeature.TARGET_TEMPERATURE_RANGE feature. Please" + "implement the ClimateEntityFeature.TARGET_TEMPERATURE_RANGE feature. " + "This will stop working in 2025.4 and raise an error instead. " + "Please" ) in caplog.text @@ -385,7 +389,8 @@ async def test_mode_validation( assert ( "MockClimateEntity sets the hvac_mode auto which is not valid " "for this entity with modes: off, heat. This will stop working " - "in 2025.3 and raise an error instead. Please" in caplog.text + "in 2025.4 and raise an error instead. " + "Please" in caplog.text ) with pytest.raises(