Add water_heater platform to cover domestic_hot_water heating#1085
Conversation
|
Warning Review limit reached
More reviews will be available in 32 minutes and 14 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR adds a complete water heater platform to the Plugwise Home Assistant integration, registering heater_central devices with DHW operation mode control and temperature management. DHW setpoint control migrates from the number platform to the new water heater entity, the select entity logic is refactored to route identifiers correctly, and all test fixtures and localization strings are updated accordingly. The plugwise package requirement is bumped to version 1.12.0 and the integration version incremented to 0.65.0. ChangesWater Heater Platform Implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
custom_components/plugwise/water_heater.py (1)
78-78: ⚡ Quick winRemove redundant device_id attribute.
Line 78 stores
self.device_id = device_id, but the parentPlugwiseEntityclass already stores this value asself._dev_id(set in the super().init call on line 77). Line 116 then usesself.device_id, which could directly useself._dev_idinstead.♻️ 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
📒 Files selected for processing (20)
custom_components/plugwise/const.pycustom_components/plugwise/coordinator.pycustom_components/plugwise/number.pycustom_components/plugwise/translations/en.jsoncustom_components/plugwise/water_heater.pytests/components/plugwise/conftest.pytests/components/plugwise/fixtures/anna_v4_dhw/data.jsontests/components/plugwise/snapshots/test_number.ambrtests/components/plugwise/snapshots/test_water_heater.ambrtests/components/plugwise/test_binary_sensor.pytests/components/plugwise/test_button.pytests/components/plugwise/test_climate.pytests/components/plugwise/test_config_flow.pytests/components/plugwise/test_diagnostics.pytests/components/plugwise/test_init.pytests/components/plugwise/test_number.pytests/components/plugwise/test_select.pytests/components/plugwise/test_sensor.pytests/components/plugwise/test_switch.pytests/components/plugwise/test_water_heater.py
💤 Files with no reviewable changes (2)
- custom_components/plugwise/number.py
- tests/components/plugwise/snapshots/test_number.ambr
8c219bc to
2e4983f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/translations/nl.json`:
- Around line 301-310: The water_heater object in the translations/nl.json file
is missing a closing brace. After the "state" object closes with its closing
brace (following the "off": "Uit" line), add another closing brace `}` with
proper indentation to properly close the "water_heater" object before the comma
that precedes the "exceptions" object. This will fix the malformed JSON
structure.
🪄 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: ee0cf205-fd55-45ff-9146-652fb05b3295
📒 Files selected for processing (23)
custom_components/plugwise/const.pycustom_components/plugwise/manifest.jsoncustom_components/plugwise/number.pycustom_components/plugwise/strings.jsoncustom_components/plugwise/switch.pycustom_components/plugwise/translations/en.jsoncustom_components/plugwise/translations/nl.jsoncustom_components/plugwise/water_heater.pytests/components/plugwise/fixtures/adam_plus_anna_new/data.jsontests/components/plugwise/fixtures/anna_heatpump_heating/data.jsontests/components/plugwise/fixtures/anna_p1/data.jsontests/components/plugwise/fixtures/anna_v4/data.jsontests/components/plugwise/fixtures/anna_v4_dhw/data.jsontests/components/plugwise/fixtures/m_adam_cooling/data.jsontests/components/plugwise/fixtures/m_adam_heating/data.jsontests/components/plugwise/fixtures/m_adam_heating_off_schedule/data.jsontests/components/plugwise/fixtures/m_adam_jip/data.jsontests/components/plugwise/fixtures/m_anna_heatpump_cooling/data.jsontests/components/plugwise/snapshots/test_number.ambrtests/components/plugwise/snapshots/test_select.ambrtests/components/plugwise/snapshots/test_water_heater.ambrtests/components/plugwise/test_number.pytests/components/plugwise/test_water_heater.py
💤 Files with no reviewable changes (4)
- custom_components/plugwise/number.py
- custom_components/plugwise/switch.py
- tests/components/plugwise/test_number.py
- tests/components/plugwise/snapshots/test_number.ambr
✅ Files skipped from review due to trivial changes (4)
- custom_components/plugwise/manifest.json
- tests/components/plugwise/fixtures/adam_plus_anna_new/data.json
- tests/components/plugwise/fixtures/m_adam_heating_off_schedule/data.json
- tests/components/plugwise/snapshots/test_water_heater.ambr
🚧 Files skipped from review as they are similar to previous changes (3)
- tests/components/plugwise/fixtures/anna_v4_dhw/data.json
- custom_components/plugwise/const.py
- tests/components/plugwise/test_water_heater.py
There was a problem hiding this comment.
🧹 Nitpick comments (1)
custom_components/plugwise/water_heater.py (1)
75-78: ⚡ Quick winRemove redundant None check after
.get()with default.Line 75 uses
.get(MAX_DHW_TEMP, {})which returns an empty dict if the key is missing, somax_dhw_temp_boundscan never beNone. Either remove theifcheck on line 76 or change line 75 to.get(MAX_DHW_TEMP)(no default) if you need to handle the missing-key case.♻️ Proposed fix
- max_dhw_temp_bounds = self.device.get(MAX_DHW_TEMP, {}) - if max_dhw_temp_bounds is not None: + if (max_dhw_temp_bounds := self.device.get(MAX_DHW_TEMP)) is not None: self._attr_max_temp = max_dhw_temp_bounds.get(UPPER_BOUND, 75.0) self._attr_min_temp = max_dhw_temp_bounds.get(LOWER_BOUND, 40.0)🤖 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` around lines 75 - 78, The None check on line 76 is redundant because the `.get(MAX_DHW_TEMP, {})` call on line 75 returns an empty dictionary as the default value, never None. Remove the `if max_dhw_temp_bounds is not None:` condition and unindent the two assignment statements for `_attr_max_temp` and `_attr_min_temp` so they always execute. This simplifies the code since the dictionary is guaranteed to exist (either populated or empty).
🤖 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.
Nitpick comments:
In `@custom_components/plugwise/water_heater.py`:
- Around line 75-78: The None check on line 76 is redundant because the
`.get(MAX_DHW_TEMP, {})` call on line 75 returns an empty dictionary as the
default value, never None. Remove the `if max_dhw_temp_bounds is not None:`
condition and unindent the two assignment statements for `_attr_max_temp` and
`_attr_min_temp` so they always execute. This simplifies the code since the
dictionary is guaranteed to exist (either populated or empty).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 352c02ab-f84c-454b-8d84-43450b48b9b0
📒 Files selected for processing (23)
custom_components/plugwise/const.pycustom_components/plugwise/manifest.jsoncustom_components/plugwise/number.pycustom_components/plugwise/strings.jsoncustom_components/plugwise/switch.pycustom_components/plugwise/translations/en.jsoncustom_components/plugwise/translations/nl.jsoncustom_components/plugwise/water_heater.pytests/components/plugwise/fixtures/adam_plus_anna_new/data.jsontests/components/plugwise/fixtures/anna_heatpump_heating/data.jsontests/components/plugwise/fixtures/anna_p1/data.jsontests/components/plugwise/fixtures/anna_v4/data.jsontests/components/plugwise/fixtures/anna_v4_dhw/data.jsontests/components/plugwise/fixtures/m_adam_cooling/data.jsontests/components/plugwise/fixtures/m_adam_heating/data.jsontests/components/plugwise/fixtures/m_adam_heating_off_schedule/data.jsontests/components/plugwise/fixtures/m_adam_jip/data.jsontests/components/plugwise/fixtures/m_anna_heatpump_cooling/data.jsontests/components/plugwise/snapshots/test_number.ambrtests/components/plugwise/snapshots/test_select.ambrtests/components/plugwise/snapshots/test_water_heater.ambrtests/components/plugwise/test_number.pytests/components/plugwise/test_water_heater.py
💤 Files with no reviewable changes (4)
- tests/components/plugwise/test_number.py
- tests/components/plugwise/snapshots/test_number.ambr
- custom_components/plugwise/switch.py
- custom_components/plugwise/number.py
✅ Files skipped from review due to trivial changes (2)
- tests/components/plugwise/fixtures/m_adam_heating/data.json
- tests/components/plugwise/snapshots/test_water_heater.ambr
🚧 Files skipped from review as they are similar to previous changes (14)
- custom_components/plugwise/strings.json
- tests/components/plugwise/fixtures/anna_p1/data.json
- tests/components/plugwise/fixtures/anna_v4_dhw/data.json
- tests/components/plugwise/fixtures/anna_v4/data.json
- custom_components/plugwise/translations/nl.json
- tests/components/plugwise/fixtures/adam_plus_anna_new/data.json
- custom_components/plugwise/manifest.json
- tests/components/plugwise/fixtures/m_adam_heating_off_schedule/data.json
- tests/components/plugwise/fixtures/anna_heatpump_heating/data.json
- tests/components/plugwise/snapshots/test_select.ambr
- custom_components/plugwise/translations/en.json
- tests/components/plugwise/test_water_heater.py
- tests/components/plugwise/fixtures/m_adam_cooling/data.json
- tests/components/plugwise/fixtures/m_anna_heatpump_cooling/data.json
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
custom_components/plugwise/strings.json (1)
109-112:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRestore missing select DHW mode translations for auto/boost.
At Line 109-Line 112,
entity.select.select_dhw_mode.stateno longer includes"auto"and"boost", while DHW mode values include these states elsewhere in this PR. This will show untranslated/raw state values in the select entity UI for those modes.Suggested fix
"select_dhw_mode": { "name": "DHW mode", "state": { + "auto": "Auto", + "boost": "Boost", "comfort": "Comfort", "off": "Off" } },🤖 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/strings.json` around lines 109 - 112, The entity.select.select_dhw_mode.state object in the strings.json file is missing translations for "auto" and "boost" modes. In the state block that currently contains only "comfort" and "off" translations (around lines 109-112), add the missing translation entries for "auto" and "boost" to ensure these DHW mode values display properly in the select entity UI instead of showing raw untranslated state values.
🤖 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.
Outside diff comments:
In `@custom_components/plugwise/strings.json`:
- Around line 109-112: The entity.select.select_dhw_mode.state object in the
strings.json file is missing translations for "auto" and "boost" modes. In the
state block that currently contains only "comfort" and "off" translations
(around lines 109-112), add the missing translation entries for "auto" and
"boost" to ensure these DHW mode values display properly in the select entity UI
instead of showing raw untranslated state values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e0ca5c68-a0f6-4d00-aad5-fcd2add433a5
📒 Files selected for processing (3)
custom_components/plugwise/strings.jsoncustom_components/plugwise/translations/en.jsoncustom_components/plugwise/translations/nl.json
🚧 Files skipped from review as they are similar to previous changes (2)
- custom_components/plugwise/translations/en.json
- custom_components/plugwise/translations/nl.json
|



Summary by CodeRabbit
Release Notes