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
This commit is contained in:
G Johansson 2024-09-25 22:22:10 +02:00 committed by GitHub
parent 82f1ccda95
commit cabd4e9d15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View File

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

View File

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