From cabd4e9d150c9d3bf04fa1b780e5f4486e542ba7 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Wed, 25 Sep 2024 22:22:10 +0200 Subject: [PATCH] Add note on target temp validation on ClimateEntity (#2299) * Add note on target temp validation on ClimateEntity * Add blog * Add back previous change * Fix review comments * Update blog --- blog/2024-09-24-climate-set-temp-validation.md | 14 ++++++++++++++ docs/core/entity/climate.md | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 blog/2024-09-24-climate-set-temp-validation.md diff --git a/blog/2024-09-24-climate-set-temp-validation.md b/blog/2024-09-24-climate-set-temp-validation.md new file mode 100644 index 00000000..e6a0f731 --- /dev/null +++ b/blog/2024-09-24-climate-set-temp-validation.md @@ -0,0 +1,14 @@ +--- +author: G Johansson +authorURL: https://github.com/gjohansson-ST +authorImageURL: https://avatars.githubusercontent.com/u/62932417?v=4 +authorTwitter: GJohansson +title: "Additional validation in Climate set temperature" +--- + +As of Home Assistant Core 2024.10, we have added further validation of the parameters passed to the `set_temperature` method. This means that integrations don't need to implement this validation in their own methods. + +Before 2024.10 it was possible to set the `temperature` parameter in the action when the entity did not set `ClimateEntityFeature.TARGET_TEMPERATURE` or `target_temp_low`/`target_temp_high` parameters when the entity did not set `ClimateEntityFeature.TARGET_TEMPERATURE_RANGE`. This will no longer be possible and a `ServiceValidationError` will be raised informing the user that they used an incorrect parameter in the action call. + +Also, when setting a temperature range, it was possible to set `target_temp_low` to a higher value than `target_temp_high`. +This will raise a `ServiceValidationError` informing the user the high value needs to be higher than the low value. diff --git a/docs/core/entity/climate.md b/docs/core/entity/climate.md index 6e728350..f6172b23 100644 --- a/docs/core/entity/climate.md +++ b/docs/core/entity/climate.md @@ -245,6 +245,10 @@ class MyClimateEntity(ClimateEntity): ### Set temperature +:::note +`ClimateEntity` has built-in validation to ensure that the `target_temperature_low` argument is lower than or equal to the `target_temperature_high` argument. Therefore, integrations do not need to validate this in their own implementation. +::: + ```python class MyClimateEntity(ClimateEntity): # Implement one of these methods.