Skip to content

Add water_heater platform to cover domestic_hot_water heating#1085

Draft
bouwew wants to merge 24 commits into
mainfrom
water_heater
Draft

Add water_heater platform to cover domestic_hot_water heating#1085
bouwew wants to merge 24 commits into
mainfrom
water_heater

Conversation

@bouwew
Copy link
Copy Markdown
Contributor

@bouwew bouwew commented Jun 7, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Plugwise water heater platform is now available, allowing users to view and control operation modes (comfort/normal) and adjust target temperatures.
  • Tests

    • Added test coverage for water heater platform functionality.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 7, 2026

Review Change Stack

Warning

Review limit reached

@bouwew, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 49 minutes and 38 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 72a50e64-f856-4cfa-bade-6cbf7af79c9e

📥 Commits

Reviewing files that changed from the base of the PR and between c425ba4 and b64f79b.

📒 Files selected for processing (1)
  • custom_components/plugwise/water_heater.py
📝 Walkthrough

Walkthrough

The PR adds a complete water heater platform to Plugwise that registers heater_central devices, manages DHW operation modes (comfort/normal), reports current and target temperatures from device state, and controls setpoints via the coordinator API. DHW temperature control is moved from the number platform to this dedicated water heater entity. Test fixtures and comprehensive snapshot tests validate both Adam and Anna device scenarios.

Changes

Water Heater Platform Implementation

Layer / File(s) Summary
Platform registration and entity implementation
custom_components/plugwise/const.py, custom_components/plugwise/water_heater.py
Platform.WATER_HEATER is registered. Water heater entity setup filters for heater_central devices with DHW state, defines comfort/normal operation modes, reports current/target temperatures from device attributes, and provides async_set_operation_mode (maps mode to DHW comfort switch) and async_set_temperature (validates support and updates MAX_DHW_TEMP via coordinator API).
Number platform DHW control migration
custom_components/plugwise/number.py, tests/components/plugwise/snapshots/test_number.ambr, tests/components/plugwise/test_number.py
MAX_DHW_TEMP import removed and NUMBER_TYPES updated to use MAX_BOILER_TEMP for boiler setpoint. Corresponding number snapshot and test case for DHW setpoint control deleted since that functionality is now in water_heater platform.
Test fixtures and snapshots
tests/components/plugwise/fixtures/anna_v4_dhw/data.json, tests/components/plugwise/snapshots/test_water_heater.ambr
New Anna V4 DHW fixture provides thermostat, gateway, and heater device test data. Water heater snapshots capture entity registry and state for Adam (DHW off, no max_dhw_temperature) and Anna (DHW on, with temperature bounds) scenarios.
Water heater platform tests
tests/components/plugwise/test_water_heater.py
Three async tests: Adam snapshot registers entity without temperature control (no max_dhw_temperature), Adam setpoint change validates set_temperature calls coordinator set_number with device hash and 65.0°C, and Anna snapshot registers entity with temperature bounds enabled (max_dhw_temperature present).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

require-dev-pass

Suggested reviewers

  • CoMPaTech
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add water_heater platform to cover domestic_hot_water heating' accurately and clearly describes the main change: adding a new water_heater platform to the Plugwise integration to support domestic hot water heating control.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch water_heater

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot requested a review from CoMPaTech June 7, 2026 12:18
@coderabbitai coderabbitai Bot added the enhancement New feature or request label Jun 7, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
custom_components/plugwise/water_heater.py (1)

78-78: ⚡ Quick win

Remove redundant device_id attribute.

Line 78 stores self.device_id = device_id, but the parent PlugwiseEntity class already stores this value as self._dev_id (set in the super().init call on line 77). Line 116 then uses self.device_id, which could directly use self._dev_id instead.

♻️ Proposed fix to use inherited _dev_id
     def __init__(
         self,
         coordinator: PlugwiseDataUpdateCoordinator,
         device_id: str,
     ) -> None:
         """Initialise the water_heater."""
         super().__init__(coordinator, device_id)
-        self.device_id = device_id
         self._attr_unique_id = f"{device_id}-water_heater"

Then update line 116:

-        await self.coordinator.api.set_number(self.device_id, MAX_DHW_TEMP, temperature)
+        await self.coordinator.api.set_number(self._dev_id, MAX_DHW_TEMP, temperature)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@custom_components/plugwise/water_heater.py` at line 78, Remove the redundant
self.device_id assignment in the water_heater constructor and use the inherited
identifier stored on the parent PlugwiseEntity as self._dev_id instead; delete
the line that sets self.device_id = device_id and replace any subsequent uses of
self.device_id (e.g., where referenced on line 116) with self._dev_id so the
class relies on the parent-stored device id.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@custom_components/plugwise/water_heater.py`:
- Around line 90-98: The current_operation property returns STATE_ON/STATE_OFF
based on self.device.get(BINARY_SENSORS, {}).get("dhw_state"), which mismatches
the component's operation_list ["heat","off"]; update current_operation (in
water_heater.py) to return MODE_HEAT when dhw_state is truthy and MODE_OFF when
falsy (use MODE_HEAT and MODE_OFF constants instead of STATE_ON/STATE_OFF) so
the returned operation values match the operation_list.
- Line 55: The current conditional in water_heater.py uses DEV_CLASS ==
"heater_central" plus checking BINARY_SENSORS.dhw_state, which causes DHW
entities to be skipped for heater_central fixtures that simply lack that key;
either (A) update the fixture/mapping data for the specific devices so they
expose binary_sensors.dhw_state if they truly support DHW, or (B) change the
code to stop assuming all heater_central devices are DHW-capable and instead
rely solely on the presence of dhw_state (replace the condition
"device[DEV_CLASS] == 'heater_central' and device.get(BINARY_SENSORS,
{}).get('dhw_state') is not None" with a check that only tests
device.get(BINARY_SENSORS, {}).get('dhw_state') is not None), ensuring DHW
entities are created only when dhw_state exists.

In `@tests/components/plugwise/snapshots/test_water_heater.ambr`:
- Line 126: The snapshot shows operation_mode='on' because the water_heater's
current_operation property is returning the wrong value; update the
current_operation property in custom_components/plugwise/water_heater.py to
consult the device's operation_list and dhw_state (or dhw_active) and return the
matching operation string (e.g., 'heat' when dhw_state is true) instead of 'on'
or a hardcoded value; ensure the property uses the same identifiers used
elsewhere (operation_list, dhw_state/current_dhw_state) and falls back safely if
the expected operation is not present, then regenerate the failing snapshot
test.

---

Nitpick comments:
In `@custom_components/plugwise/water_heater.py`:
- Line 78: Remove the redundant self.device_id assignment in the water_heater
constructor and use the inherited identifier stored on the parent PlugwiseEntity
as self._dev_id instead; delete the line that sets self.device_id = device_id
and replace any subsequent uses of self.device_id (e.g., where referenced on
line 116) with self._dev_id so the class relies on the parent-stored device id.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c08a6d55-857c-4383-88c8-b0e63557a0e1

📥 Commits

Reviewing files that changed from the base of the PR and between 698972a and 380307f.

📒 Files selected for processing (20)
  • custom_components/plugwise/const.py
  • custom_components/plugwise/coordinator.py
  • custom_components/plugwise/number.py
  • custom_components/plugwise/translations/en.json
  • custom_components/plugwise/water_heater.py
  • tests/components/plugwise/conftest.py
  • tests/components/plugwise/fixtures/anna_v4_dhw/data.json
  • tests/components/plugwise/snapshots/test_number.ambr
  • tests/components/plugwise/snapshots/test_water_heater.ambr
  • tests/components/plugwise/test_binary_sensor.py
  • tests/components/plugwise/test_button.py
  • tests/components/plugwise/test_climate.py
  • tests/components/plugwise/test_config_flow.py
  • tests/components/plugwise/test_diagnostics.py
  • tests/components/plugwise/test_init.py
  • tests/components/plugwise/test_number.py
  • tests/components/plugwise/test_select.py
  • tests/components/plugwise/test_sensor.py
  • tests/components/plugwise/test_switch.py
  • tests/components/plugwise/test_water_heater.py
💤 Files with no reviewable changes (2)
  • custom_components/plugwise/number.py
  • tests/components/plugwise/snapshots/test_number.ambr

Comment thread custom_components/plugwise/water_heater.py
Comment thread custom_components/plugwise/water_heater.py
Comment thread tests/components/plugwise/snapshots/test_water_heater.ambr
@coderabbitai coderabbitai Bot added the require-dev-pass Require actions to pass against HA dev-branch (and silently fail on HA master-branch) label Jun 7, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Error while testing for Development HA-core:

⚠️ Warning: Incompatible while testing against dev HA-core.
✔️ Success: No problem with testing against released HA-core.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Error while testing for Development HA-core:

Error: Incompatible while testing against dev HA-core and required to pass.
✔️ Success: No problem with testing against released HA-core.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 7, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

⚠️ Warning while testing for RELEASED HA-core:

✔️ Success: No problem with testing against dev HA-core.
✔️ Success: No problem with testing against released HA-core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request require-dev-pass Require actions to pass against HA dev-branch (and silently fail on HA master-branch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant