Skip to content

Add heat pump sensors to ViCare integration#161422

Merged
joostlek merged 1 commit intohome-assistant:devfrom
lackas:vicare-add-heatpump-sensors
Feb 23, 2026
Merged

Add heat pump sensors to ViCare integration#161422
joostlek merged 1 commit intohome-assistant:devfrom
lackas:vicare-add-heatpump-sensors

Conversation

@lackas
Copy link
Copy Markdown
Contributor

@lackas lackas commented Jan 22, 2026

Proposed change

Add heat pump sensors to the ViCare integration for Viessmann heat pumps (e.g. Vitocal 300-G).

New sensors (14 total):

  • Coefficient of Performance (COP): heating, DHW, total, cooling
  • Compressor: rated power (kW), modulation (%)
  • Refrigerant circuit: hot gas / suction gas / liquid gas temperatures and pressures
  • Primary circuit pump: rotation speed (%)

These sensors are only created for devices that report as heat pumps (type:heatpump). All sensors use EntityCategory.DIAGNOSTIC and SensorStateClass.MEASUREMENT (except compressor_power which is a fixed rated value).

Depends on PyViCare methods added in PyViCare#689 (merged), included in PyViCare 2.58.0 which was bumped in #163686 (merged).

Type of change

  • New feature (which adds functionality to an existing integration)

Additional information

  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

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:

@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @CFenner, mind taking a look at this pull request as it has been labeled with an integration (vicare) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of vicare 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 vicare 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, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

epenet
epenet previously requested changes Jan 22, 2026
Copy link
Copy Markdown
Contributor

@epenet epenet left a comment

Choose a reason for hiding this comment

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

This PR depends on corresponding changes to the PyViCare library: openviess/PyViCare#688

If this is not actionnable, please keep in draft until the library has been updated and bumped inside Home Assistant

@home-assistant home-assistant Bot marked this pull request as draft January 22, 2026 08:39
@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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f98ce40d14

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1030 to +1032
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
value_getter=lambda api: api.getCoefficientOfPerformanceHeating(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bump PyViCare to match new COP APIs

These new sensors call api.getCoefficientOfPerformanceHeating() (and the other COP getters added here), but homeassistant/components/vicare/manifest.json still pins PyViCare==2.55.1. The commit message notes these APIs come from a newer PyViCare PR, so with the currently pinned version this call will raise AttributeError during ViCareSensor.update, breaking the new entities on a standard install. Please update the PyViCare requirement (and regenerate requirements_all.txt) to a version that includes these methods.

Useful? React with 👍 / 👎.

Comment on lines +1101 to +1108
ViCareSensorEntityDescription(
key="cop_green",
translation_key="cop_green",
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
value_getter=lambda api: api.getCoefficientOfPerformanceGreen(),
entity_registry_enabled_default=False,
),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We did not implement this.

Suggested change
ViCareSensorEntityDescription(
key="cop_green",
translation_key="cop_green",
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
value_getter=lambda api: api.getCoefficientOfPerformanceGreen(),
entity_registry_enabled_default=False,
),

Comment on lines +265 to +267
"cop_green": {
"name": "Coefficient of performance - green"
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"cop_green": {
"name": "Coefficient of performance - green"
},

Comment on lines +1301 to +1303
native_unit_of_measurement=PERCENTAGE,
value_getter=lambda api: api.getModulation(),
unit_getter=lambda api: api.getModulationUnit(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just out of curiosity, not saying that it is wrong, but why is there both native_unit_of_measurement and unit_getter for this? Can the unit change in the API?

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.

The unit_getter is a pattern used across several ViCare sensors (e.g. supply_pressure, primary_circuit_pump_rotation). It queries the device for the unit it reports in, allowing the sensor to adapt if different models/regions use different units. For compressor_power specifically, it likely always returns kilowatt, but we follow the same defensive pattern for consistency.

@lackas lackas marked this pull request as ready for review February 23, 2026 09:35
Copilot AI review requested due to automatic review settings February 23, 2026 09:35
@home-assistant home-assistant Bot requested review from CFenner and epenet February 23, 2026 09:35
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

This pull request adds 15 new heat pump-specific sensors to the ViCare integration for Viessmann heat pumps, enhancing monitoring capabilities for heat pump operations. The changes depend on PyViCare 2.58.0 which has already been merged in PR #163686.

Changes:

  • Added 5 Coefficient of Performance (COP) sensors tracking efficiency metrics for heating, DHW, total, cooling, and green modes
  • Added 2 compressor sensors (power and modulation) to monitor compressor operation
  • Added 6 refrigerant circuit sensors tracking hot gas, suction gas, and liquid gas temperatures and pressures
  • Added 1 primary circuit pump rotation sensor
  • Updated translations in strings.json for all new sensor keys

Reviewed changes

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

File Description
homeassistant/components/vicare/sensor.py Added 15 new sensor definitions across GLOBAL_SENSORS and COMPRESSOR_SENSORS tuples with appropriate entity categories, state classes, and device classes
homeassistant/components/vicare/strings.json Added translation keys for all new sensors with descriptive names following integration conventions
tests/components/vicare/snapshots/test_sensor.ambr Added snapshot test data for new sensors validating entity registry and state attributes

value_getter=lambda api: api.getPower(),
unit_getter=lambda api: api.getPowerUnit(),
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The compressor_power sensor should have entity_category set to EntityCategory.DIAGNOSTIC for consistency with the integration's diagnostic sensor patterns. Looking at similar power sensors in the codebase (e.g., inverter_power at line 1462), and considering this is a component-level metric similar to compressor_starts and compressor_hours (which are DIAGNOSTIC), this sensor should be marked as diagnostic. Currently, it's set to None, which makes it appear as a primary entity.

Suggested change
state_class=SensorStateClass.MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,

Copilot uses AI. Check for mistakes.
Comment on lines +1298 to +1305
ViCareSensorEntityDescription(
key="compressor_modulation",
translation_key="compressor_modulation",
native_unit_of_measurement=PERCENTAGE,
value_getter=lambda api: api.getModulation(),
unit_getter=lambda api: api.getModulationUnit(),
state_class=SensorStateClass.MEASUREMENT,
),
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The compressor_modulation sensor is defined in the code but is not present in the test fixture data (Vitocal222G_Vitovent300W.json). While this is not necessarily incorrect (the sensor may only be available on certain heat pump models), it would be beneficial to verify this is intentional. If this sensor is expected to be available on the test device, the fixture data should be updated to include it. Otherwise, consider adding a comment explaining why this sensor is not present in all heat pump models.

Copilot uses AI. Check for mistakes.
Comment on lines +4422 to +4461
# name: test_all_entities[sensor.model2_compressor_power-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.model2_compressor_power',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Compressor power',
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
}),
'original_device_class': <SensorDeviceClass.POWER: 'power'>,
'original_icon': None,
'original_name': 'Compressor power',
'platform': 'vicare',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'compressor_power',
'unique_id': 'gateway2_################-compressor_power-0',
'unit_of_measurement': <UnitOfPower.KILO_WATT: 'kW'>,
})
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The test snapshot shows entity_category as None for this sensor, but based on the code review at lines 1289-1297 in sensor.py, this should be EntityCategory.DIAGNOSTIC. After fixing the entity_category in the sensor definition, this snapshot will need to be regenerated to reflect the correct entity_category value of 'diagnostic'.

Copilot uses AI. Check for mistakes.
@lackas lackas force-pushed the vicare-add-heatpump-sensors branch from 70ee425 to dcde619 Compare February 23, 2026 09:54
Copilot AI review requested due to automatic review settings February 23, 2026 10:04
@lackas lackas force-pushed the vicare-add-heatpump-sensors branch from dcde619 to 445f30d Compare February 23, 2026 10:04
Copy link
Copy Markdown
Contributor Author

@lackas lackas left a comment

Choose a reason for hiding this comment

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

Thanks for catching this! getCoefficientOfPerformanceGreen() doesn't exist in PyViCare. Removed the sensor and its strings.json entry. Also made compressor_power EntityCategory.DIAGNOSTIC since it's a fixed rated value, not a live measurement.

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 3 out of 3 changed files in this pull request and generated 1 comment.

Comment on lines +1072 to +1100
ViCareSensorEntityDescription(
key="cop_heating",
translation_key="cop_heating",
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
value_getter=lambda api: api.getCoefficientOfPerformanceHeating(),
),
ViCareSensorEntityDescription(
key="cop_dhw",
translation_key="cop_dhw",
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
value_getter=lambda api: api.getCoefficientOfPerformanceDHW(),
),
ViCareSensorEntityDescription(
key="cop_total",
translation_key="cop_total",
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
value_getter=lambda api: api.getCoefficientOfPerformanceTotal(),
),
ViCareSensorEntityDescription(
key="cop_cooling",
translation_key="cop_cooling",
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
value_getter=lambda api: api.getCoefficientOfPerformanceCooling(),
entity_registry_enabled_default=False,
),
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The PR description states there are 15 new sensors and mentions a "green COP" sensor, but the code only adds 12 sensors (4 refrigerant circuit temperatures/pressures, 4 COP sensors, 1 pump rotation, 2 compressor sensors, and 1 primary circuit pump). The "green COP" sensor is not implemented. Please update the PR description to accurately reflect the 12 sensors actually being added: COP (heating, DHW, total, cooling), compressor (power, modulation), refrigerant circuit (hot gas/suction gas/liquid gas temperatures and hot gas/suction gas pressures), and primary circuit pump rotation.

Copilot uses AI. Check for mistakes.
value_getter=lambda api: api.getPower(),
unit_getter=lambda api: api.getPowerUnit(),
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
Copy link
Copy Markdown
Contributor

@CFenner CFenner Feb 23, 2026

Choose a reason for hiding this comment

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

@lackas you say this is no measurement but a fixed value? Then I think we should change this.

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, looking at the available test data, heating.compressors.0.power is a fixed rated value across all fixtures (8 kW on 222G/333G, 10 kW on 200S, 12 kW on 300-G). Removed SensorStateClass.MEASUREMENT and kept it as EntityCategory.DIAGNOSTIC — it's still useful as a spec/reference value. Pushed.

Add support for additional heat pump sensors:
- Coefficient of Performance (COP): heating, DHW, total, cooling, green
- Compressor: power output and modulation percentage
- Refrigerant circuit: hot gas, suction gas, and liquid gas pressures/temperatures
- Primary circuit pump rotation
@lackas lackas force-pushed the vicare-add-heatpump-sensors branch from 445f30d to 3de4ec5 Compare February 23, 2026 10:38
@CFenner
Copy link
Copy Markdown
Contributor

CFenner commented Feb 23, 2026

Please avoid force pushed to ease review.

Copy link
Copy Markdown
Contributor

@CFenner CFenner left a comment

Choose a reason for hiding this comment

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

👍

@joostlek joostlek merged commit ea7732e into home-assistant:dev Feb 23, 2026
33 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 24, 2026
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.

6 participants