8000 Add `required_features` to WaterHeater entity service registrations by zxdavb · Pull Request #141873 · home-assistant/core · GitHub
[go: up one dir, main page]

Skip to content

Add required_features to Water 10000 Heater entity service registrations #141873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 3, 2025

Conversation

zxdavb
Copy link
Contributor
@zxdavb zxdavb commented Mar 30, 2025

Proposed change

When WaterHeater entity services are registered by the platform, some do not specify the corresponding required_features (e.g. WaterHeaterEntityFeature.OPERATION_MODE).

This results in odd behaviour, such as #141868.

This PR addresses those omission (see initial commit).

This fix had the potential to be a breaking change, as integrations that support these services but that have not added the corresponding WaterHeaterEntityFeature to _attr_supported_features (or similar) will no longer expose that service.

Thus, all water heaters were individually checked by hand.

These have needed a fix:

I am unable to add tests to the Hive integration, and so coverage is failing there.

These seem OK, and should work as before:

  • demo - although: has an unrelated bug of uncertain impact?
  • econet - does not use _attr_supported_features, no test_water_heater.py

These are/were OK:

  • airzone
  • airzone_cloud
  • aosmith - does not use _attr_supported_features
  • bsblan
  • geniushub - no test_water_heater.py
  • incomfort - does not have any methods
  • lg_thinq - no test_water_heater.py
  • matter
  • melcloud - no test_water_heater.py
  • mqtt
  • nibe_heatpump - no test_water_heater.py
  • osoenergy
  • smartthings - does not use _attr_supported_features
  • tado
  • vicare

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

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

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.

@zxdavb zxdavb marked this pull request as draft March 30, 2025 20:52
@zxdavb zxdavb changed the title WIP: Add required_features to service calls Add required_features to water_heater service calls Mar 30, 2025
@zxdavb
Copy link
Contributor Author
zxdavb commented May 28, 2025

All water heaters found via ls homeassistant/components/*/water_heater.py > water_heaters.txt.

Not all have tests.

After initial commit, running pytest $(cat water_heaters.txt), only one failure:

Results (80.75s (0:01:20)):
     999 passed
       1 failed
         - tests/components/atag/test_water_heater.py:35 test_setting_target_temperature
     217 error

Each water_heater.py was checked for these methods:

  • set_operation_mode
  • set_temperature
  • turn_on (and off)
  • turn_away_mode_on and (off)

@zxdavb
Copy link
Contributor Author
zxdavb commented May 28, 2025

The econet integration includes the following:

    def supported_features(self) -> WaterHeaterEntityFeature:
        """Return the list of supported features."""
        if self.water_heater.modes:
            if self.water_heater.supports_away:
                return SUPPORT_FLAGS_HEATER | WaterHeaterEntityFeature.AWAY_MODE
            return SUPPORT_FLAGS_HEATER
        if self.water_heater.supports_away:
            return (
                WaterHeaterEntityFeature.TARGET_TEMPERATURE
                | WaterHeaterEntityFeature.AWAY_MODE
            )
        return WaterHeaterEntityFeature.TARGET_TEMPERATURE

I am not 100% confident that this is OK, although SUPPORT_FLAGS_HEATER includes WaterHeaterEntityFeature.OPERATION_MODE.

@w1ll1am23, could you check it for me, please?

@zxdavb zxdavb marked this pull request as ready for review May 28, 2025 21:51
@zxdavb zxdavb changed the title Add required_features to water_heater service calls Add required_features to water_heater service call registrations May 28, 2025
@zxdavb zxdavb changed the title Add required_features to water_heater service call registrations Add required_features to WaterHeater entity service registrations May 28, 2025
@w1ll1am23
Copy link
Contributor

@zxdavb I no longer have a water heater hooked up to econets API but this change seems like it would be okay to me.

Copy link
Member
@frenck frenck left a comment

Choose a reason for hiding this comment

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

Nice! Thanks, @zxdavb 👍

../Frenck

@frenck frenck merged commit c254548 into home-assistant:dev Jun 3, 2025
47 of 48 checks passed
@zxdavb zxdavb deleted the core_bugfix_water_heater branch June 3, 2025 12:39
@github-actions github-actions bot locked and limited conversation to collaborators Jun 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WaterHeater does not specify required_features for some entity services
3 participants
0