Skip to content

Add switch platform to Qube heat pump#169407

Open
MattieGit wants to merge 2 commits intohome-assistant:devfrom
MattieGit:add-qube-switches
Open

Add switch platform to Qube heat pump#169407
MattieGit wants to merge 2 commits intohome-assistant:devfrom
MattieGit:add-qube-switches

Conversation

@MattieGit
Copy link
Copy Markdown
Contributor

@MattieGit MattieGit commented Apr 28, 2026

Proposed change

Add a switch platform to the hr_energy_qube integration with 4 switch entities for controlling the heat pump via Modbus coil registers: summer mode, anti-legionella cycle, heating curve, and heating demand. DHW boost is handled by a separate water_heater entity in #169851.

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

  • I understand the code I am submitting and can explain how it works.
  • 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.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

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 diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copy link
Copy Markdown
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

Adds a switch platform to the hr_energy_qube integration and updates the coordinator data model to include both the existing QubeState data and Modbus coil switch states.

Changes:

  • Introduces 5 new switch entities backed by Modbus coil registers, including write support + error handling.
  • Updates the coordinator to return a combined QubeDeviceData object (state + switches) and updates sensors/binary sensors to read via data.state.*.
  • Adds switch-focused tests (snapshot + on/off + error handling) and extends the shared test client fixture to mock switch read/write APIs.

Reviewed changes

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

Show a summary per file
File Description
homeassistant/components/hr_energy_qube/const.py Enables forwarding the new switch platform.
homeassistant/components/hr_energy_qube/models.py Adds QubeDeviceData to combine state + switch data.
homeassistant/components/hr_energy_qube/coordinator.py Fetches both get_all_data() and read_all_switches() per update.
homeassistant/components/hr_energy_qube/sensor.py Updates sensor value functions to read from QubeDeviceData.state.
homeassistant/components/hr_energy_qube/binary_sensor.py Updates binary sensor value functions to read from QubeDeviceData.state.
homeassistant/components/hr_energy_qube/switch.py New switch platform + entities, including write and refresh behavior.
homeassistant/components/hr_energy_qube/strings.json Adds exception translation and switch entity names.
tests/components/hr_energy_qube/conftest.py Extends mocked client to support read_all_switches() and write_switch().
tests/components/hr_energy_qube/test_switch.py Adds switch entity snapshots and functional tests for on/off + error cases.
tests/components/hr_energy_qube/snapshots/test_switch.ambr Snapshot coverage for the new switch entities.

Comment thread homeassistant/components/hr_energy_qube/coordinator.py Outdated
Comment thread homeassistant/components/hr_energy_qube/switch.py
@MattieGit
Copy link
Copy Markdown
Contributor Author

Copilot AI review requested due to automatic review settings April 28, 2026 21:01
Copy link
Copy Markdown
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 10 out of 10 changed files in this pull request and generated 1 comment.

Comment thread tests/components/hr_energy_qube/test_switch.py Outdated
Comment thread homeassistant/components/hr_energy_qube/binary_sensor.py Outdated
Comment thread homeassistant/components/hr_energy_qube/models.py Outdated
@MattieGit MattieGit force-pushed the add-qube-switches branch 2 times, most recently from 1e032c6 to 0dcb411 Compare April 29, 2026 08:01
Copilot AI review requested due to automatic review settings April 29, 2026 08:06
Copy link
Copy Markdown
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 7 out of 7 changed files in this pull request and generated 3 comments.

Comment thread tests/components/hr_energy_qube/test_switch.py Outdated
Comment thread tests/components/hr_energy_qube/test_switch.py
Comment thread tests/components/hr_energy_qube/test_switch.py Outdated
Comment thread homeassistant/components/hr_energy_qube/coordinator.py Outdated
Comment on lines +207 to +218
"dhw_boost": {
"name": "DHW boost"
},
"heating_curve": {
"name": "Heating curve"
},
"heating_demand": {
"name": "Heating demand"
},
"summer_mode_switch": {
"name": "Summer mode"
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  1. DHW Boost, is that separate from a water_heater preset mode?
  2. Summer mode, is that comparable to a holiday mode where the device goes into low energy mode and what not?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

DHW Boost forces an immediate DHW heating cycle regardless of the schedule. This is helpful when you have surplus energy available and want to use that for DHW heating.

Summer mode: It toggles the heat pump between heating and cooling mode. It's not a "holiday/low energy" mode. It's switching the operational mode from central heating to active cooling. Later on this could be part of a climate entity, but that's not implemented yet (up for the next PR).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is DHW boost something that we should make a preset mode or main mode? https://developers.home-assistant.io/docs/core/entity/water-heater#states

It might fit PERFORMANCE or HIGH_DEMAND

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I like that idea. Would that mean the integration will eventually have a combined water heater entity and a climate entity?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I mean, a climate entity is supposed to heat your house, while water_heater is for DHW

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I understand. I was asking, because every owner of the Qube system will have both a heat pump and water heater in an integrated system. They might use HA to actually control heating and DHW, but it's also possible they only want to see the status and let the included thermostat take care of managing climate and DHW.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@joostlek How about the following approach?
I'll add a water_heater entity in a follow-up PR that consolidates DHW temperature, setpoint, and boost into a single entity (with DHW boost as a preset mode). For users who only want to monitor, the entity will still show current temperature and operation state without requiring them to actively control it. For now I'll keep the DHW boost switch in this PR as a stepping stone.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes but they'd view that status via the water_heater entity. As in it'd change from "the heatpump has boost mode turned on" to "the heatpump is in the boost mode state/preset", and the latter might be easier to grasp

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, makes sense! I'll remove that switch from this PR and will create a new PR with the water heater entity and the preset mode.

Copilot AI review requested due to automatic review settings April 29, 2026 19:00
Copy link
Copy Markdown
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 7 out of 7 changed files in this pull request and generated 3 comments.

Comment thread homeassistant/components/hr_energy_qube/switch.py Outdated
Comment thread homeassistant/components/hr_energy_qube/switch.py
Comment thread homeassistant/components/hr_energy_qube/coordinator.py
Copy link
Copy Markdown
Member

@erwindouna erwindouna left a comment

Choose a reason for hiding this comment

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

The PR template is tempered with. Please restore it.

@home-assistant home-assistant Bot marked this pull request as draft April 30, 2026 09:17
@home-assistant
Copy link
Copy Markdown
Contributor

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@erwindouna
Copy link
Copy Markdown
Member

Docs PR: home-assistant/home-assistant.io#45063

Please include this in the PR template.

Comment thread homeassistant/components/hr_energy_qube/coordinator.py Outdated
Comment thread homeassistant/components/hr_energy_qube/switch.py Outdated
Comment thread homeassistant/components/hr_energy_qube/switch.py Outdated
Comment thread tests/components/hr_energy_qube/test_switch.py
Comment thread tests/components/hr_energy_qube/test_switch.py Outdated
Comment thread homeassistant/components/hr_energy_qube/switch.py
@home-assistant home-assistant Bot marked this pull request as draft May 1, 2026 07:16
@MattieGit MattieGit marked this pull request as ready for review May 1, 2026 08:28
Copilot AI review requested due to automatic review settings May 1, 2026 08:28
@home-assistant home-assistant Bot requested a review from erwindouna May 1, 2026 08:28
Copy link
Copy Markdown
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 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread homeassistant/components/hr_energy_qube/coordinator.py Outdated
Copilot AI review requested due to automatic review settings May 5, 2026 08:03
Copy link
Copy Markdown
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 7 out of 7 changed files in this pull request and generated 3 comments.

Comment thread homeassistant/components/hr_energy_qube/coordinator.py
Comment thread tests/components/hr_energy_qube/test_switch.py
Comment thread tests/components/hr_energy_qube/test_switch.py
Copy link
Copy Markdown
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

Please leave the new platform for a later PR

@home-assistant home-assistant Bot marked this pull request as draft May 5, 2026 09:06
Copilot AI review requested due to automatic review settings May 5, 2026 14:11
Copy link
Copy Markdown
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 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread homeassistant/components/hr_energy_qube/switch.py
@MattieGit
Copy link
Copy Markdown
Contributor Author

Please leave the new platform for a later PR

Yes, accidentally added the platform to this PR. Reverted and created a new PR for the water heater platform.

@MattieGit MattieGit marked this pull request as ready for review May 5, 2026 18:39
Copilot AI review requested due to automatic review settings May 5, 2026 18:39
@home-assistant home-assistant Bot requested a review from joostlek May 5, 2026 18:40
Copy link
Copy Markdown
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 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread homeassistant/components/hr_energy_qube/switch.py
Comment thread homeassistant/components/hr_energy_qube/switch.py
Copilot AI review requested due to automatic review settings May 5, 2026 18:59
Copy link
Copy Markdown
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 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread tests/components/hr_energy_qube/test_switch.py Outdated
Comment thread tests/components/hr_energy_qube/test_switch.py
Add 4 switch entities for controlling the heat pump via Modbus
coil registers:

- Summer mode: toggle between heating and cooling
- Anti-legionella cycle: manually start anti-legionella
- Heating curve: enable/disable dynamic heating curve (config)
- Heating demand: activate heating demand via Modbus

Switch state is polled alongside sensor data in the coordinator
and stored as a separate attribute. Switch read failures are
handled independently so sensors remain available. Writes use
the library's write_switch() API with error handling, optimistic
state update, and coordinator refresh.
Copilot AI review requested due to automatic review settings May 6, 2026 19:06
@MattieGit MattieGit force-pushed the add-qube-switches branch from 2d71cce to 640b68b Compare May 6, 2026 19:06
Copy link
Copy Markdown
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 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread tests/components/hr_energy_qube/test_switch.py Outdated
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.

5 participants