Skip to content

Conversation

@gjohansson-ST
Copy link
Member

@gjohansson-ST gjohansson-ST commented Jul 5, 2025

Proposed change

This PR adds target temperature range functionality to the water_heater component, allowing water heaters to specify both high and low target temperature setpoints. This mirrors similar functionality in the climate component and was approved through an architecture discussion #995.
The implementation includes:

  • a new TARGET_TEMPERATURE_RANGE entity feature flag,
  • validation to ensure proper feature support,
  • comprehensive test coverage for both single target temperature and temperature range scenarios.

Key changes:

  • Added TARGET_TEMPERATURE_RANGE feature flag and related attributes (target_temp_high, target_temp_low)
  • Updated service schema to support exclusive temperature parameters with proper validation
  • Implemented state reproduction logic to handle temperature ranges
  • Added comprehensive tests and demo entities

TODO: Needs a frontend PR

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • This PR is related to architecture/discussions: #995
  • Link to documentation pull request:
  • Link to dev documentation pull request: #2720

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link

home-assistant bot commented Jul 5, 2025

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (water_heater) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of water_heater can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign water_heater Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@lboue
Copy link
Contributor

lboue commented Aug 21, 2025

Hi,
Is there any news about this request?

@lboue lboue changed the title Add target temp range to water_heater Add target temp range to water_heater Nov 22, 2025
@lboue lboue marked this pull request as ready for review November 22, 2025 17:35
Copilot AI review requested due to automatic review settings November 22, 2025 17:35
@lboue lboue requested a review from a team as a code owner November 22, 2025 17:35
Copilot finished reviewing on behalf of lboue November 22, 2025 17:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds target temperature range functionality to the water_heater component, allowing water heaters to specify both high and low target temperature setpoints. This mirrors similar functionality in the climate component and was approved through an architecture discussion. The implementation includes a new TARGET_TEMPERATURE_RANGE entity feature flag, validation to ensure proper feature support, and comprehensive test coverage for both single target temperature and temperature range scenarios.

Key changes:

  • Added TARGET_TEMPERATURE_RANGE feature flag and related attributes (target_temp_high, target_temp_low)
  • Updated service schema to support exclusive temperature parameters with proper validation
  • Implemented state reproduction logic to handle temperature ranges
  • Added comprehensive tests and demo entities

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
homeassistant/components/water_heater/__init__.py Added TARGET_TEMPERATURE_RANGE feature flag, updated schema to support temp ranges with exclusive/inclusive validation, and added service handler validation
homeassistant/components/water_heater/services.yaml Added target_temp_high and target_temp_low fields with appropriate feature filters
homeassistant/components/water_heater/strings.json Added error messages and field descriptions for temperature range parameters
homeassistant/components/water_heater/reproduce_state.py Added logic to reproduce temperature range states alongside single temperature
homeassistant/components/demo/water_heater.py Added demo entity showcasing temperature range functionality
tests/components/water_heater/test_init.py Added comprehensive tests for both target temperature and temperature range scenarios with validation checks
tests/components/water_heater/test_reproduce_state.py Added tests for reproducing water heater states with temperature ranges
tests/components/water_heater/conftest.py Added test fixture for integration setup

…hod in an executor to avoid blocking the event loop.
…sly in the event loop, to avoid thread safety violations with legacy synchronous implementations.
@lboue lboue requested a review from Copilot November 22, 2025 21:29
Copilot finished reviewing on behalf of lboue November 22, 2025 21:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment on lines 112 to 114
def set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperatures."""
self._attr_target_temperature = kwargs.get(ATTR_TEMPERATURE)
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set_temperature method only handles ATTR_TEMPERATURE but doesn't handle ATTR_TARGET_TEMP_HIGH and ATTR_TARGET_TEMP_LOW parameters. The demo entity for temperature range will not work correctly when the service is called. Add handling for these parameters similar to the test mock entities in test_init.py.

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +38
target_temp_high:
filter:
supported_features:
- water_heater.WaterHeaterEntityFeature.TARGET_TEMPERATURE_RANGE
advanced: true
selector:
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The target_temp_high and target_temp_low fields are missing the required: true declaration. While they use vol.Inclusive in the schema (which requires both when one is present), the services.yaml should also reflect this requirement for UI clarity. Consider adding required: false explicitly since they are only required together as a pair, not individually.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants