Add target temp range to water heater

This commit is contained in:
G Johansson 2025-07-07 18:42:01 +00:00
parent 8de9ba5404
commit e86c6f96cb
2 changed files with 41 additions and 7 deletions

View File

@ -0,0 +1,33 @@
---
author: G Johansson
authorURL: https://github.com/gjohansson-ST
authorImageURL: https://avatars.githubusercontent.com/u/62932417?v=4
authorTwitter: GJohansson
title: "Water heater now supports setting a temperature range"
---
As of Home Assistant Core 2025.8, the `WaterHeaterEntity` now also supports setting a temperature range in addition to only setting a temperature.
Entities needs to set the `TARGET_TEMPERATURE_RANGE` supported feature to enable use of setting a target temperature range.
```python
from homeassistant.components.water_heater import WaterHeaterEntity, WaterHeaterEntityFeature
class MyWaterHeater(WaterHeaterEntity):
"""My water heater."""
@property
def supported_features(self) -> WaterHeaterEntityFeature:
"""Return the supported features."""
return WaterHeaterEntityFeature.TARGET_TEMPERATURE_RANGE
async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperature."""
min_temp = kwargs[ATTR_TARGET_TEMP_LOW]
max_temp = kwargs[ATTR_TARGET_TEMP_HIGH]
self.my_device.set_temperature(min_tenp, max_temp)
```
More details can be found in the [water_heater documentation](/docs/core/entity/water-heater#supported-features).

View File

@ -48,17 +48,18 @@ Supported features are defined by using values in the `WaterHeaterEntityFeature`
and are combined using the bitwise or (`|`) operator. and are combined using the bitwise or (`|`) operator.
| Value | Description | | Value | Description |
| -------------------- | ------------------------- | | --------------------------- | ------------------------------ |
| `TARGET_TEMPERATURE` | Temperature can be set | | `TARGET_TEMPERATURE` | Temperature can be set |
| `OPERATION_MODE` | Operation mode can be set | | `OPERATION_MODE` | Operation mode can be set |
| `AWAY_MODE` | Away mode can be set | | `AWAY_MODE` | Away mode can be set |
| `ON_OFF` | Can be turned on or off | | `ON_OFF` | Can be turned on or off |
| `TARGET_TEMPERATURE_RANGE` | Temperature range can be set |
## Methods ## Methods
### `set_temperature` or `async_set_temperature` ### `set_temperature` or `async_set_temperature`
Sets the temperature the water heater should heat water to. Sets the temperature or temperature range the water heater should heat water to.
### `set_operation_mode`or `async_set_operation_mode` ### `set_operation_mode`or `async_set_operation_mode`