Add water_heater platform to cover domestic_hot_water heating#1085
Add water_heater platform to cover domestic_hot_water heating#1085bouwew wants to merge 24 commits into
Conversation
|
Warning Review limit reached
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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe 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. ChangesWater Heater Platform Implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
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
|



Summary by CodeRabbit
Release Notes
New Features
Tests