Improve logging message for validation in climate (#125837)

This commit is contained in:
G Johansson 2024-09-12 21:41:00 +02:00 committed by GitHub
parent d530fd31b0
commit d259e4512b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 6 deletions

View file

@ -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__,

View file

@ -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(