Prana Integration - Refactoring#168639
Prana Integration - Refactoring#168639LucaTheHacker wants to merge 2 commits intohome-assistant:devfrom
Conversation
There was a problem hiding this comment.
Hello @LucaTheHacker,
When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).
The commits that are missing a linked GitHub account are the following:
71e47345e808b82734f33c6a88d7dd45666eb774- No email found attached to the commit.
Unfortunately, we are unable to accept this pull request until this situation is corrected.
Here are your options:
-
If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.
-
If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.
- If you only made a single commit you should be able to run
(substituting "Author Name" and "
git commit --amend --author="Author Name <email@address.com>"email@address.com" for your actual information) to set the authorship information. - If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
- You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
- You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
- Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.
- If you only made a single commit you should be able to run
We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.
Thanks, I look forward to checking this PR again soon! ❤️
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
Hey there @prana-dev-official, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull request overview
Refactors the Prana integration’s entity model to better align with Home Assistant fan patterns, including consolidating “linked/bound” devices into a single ventilation fan and moving operating modes to fan preset modes.
Changes:
- Restructures fan entities: linked models expose one “ventilation” fan; split models expose separate supply/extract fans with preset modes.
- Simplifies switches to only anti-ice toggles (heater, winter) and removes the prior “mode-like” switches.
- Adjusts temperature sensors to expose only inside/outside sensors with a fallback workaround for upstream mislabeling.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/prana/fan.py |
Implements linked vs split fan entity selection and adds preset modes. |
homeassistant/components/prana/switch.py |
Removes bound/auto/auto_plus switches, leaving heater/winter toggles. |
homeassistant/components/prana/sensor.py |
Drops *_2 temperature entities and adds swapped-field fallback logic. |
homeassistant/components/prana/strings.json |
Updates entity strings for new fan preset modes and removes old switch/sensor entries. |
homeassistant/components/prana/icons.json |
Adds icons for ventilation preset modes and removes old entity icons. |
tests/components/prana/test_fan.py |
Updates fan tests for linked vs split behavior and API targeting. |
tests/components/prana/test_switch.py |
Updates switch action tests to match remaining toggles. |
tests/components/prana/snapshots/test_fan.ambr |
Deleted snapshot file for fan snapshot tests. |
tests/components/prana/snapshots/test_switch.ambr |
Deleted snapshot file for switch snapshot tests. |
tests/components/prana/snapshots/test_sensor.ambr |
Deleted snapshot file for sensor snapshot tests. |
| """Test the Prana fans snapshot (linked model, default fixture).""" | ||
| with patch("homeassistant.components.prana.PLATFORMS", [Platform.FAN]): | ||
| await async_init_integration(hass, mock_config_entry) | ||
|
|
||
| return target, fan_mock_state | ||
| await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) |
There was a problem hiding this comment.
Regenerate and commit the Syrupy snapshot for this test; the test still calls snapshot_platform but the corresponding test_fan snapshot file was removed, which will cause CI snapshot failures.
| # Devices only have two physical probes (one inside, one outside), but | ||
| # the upstream library mislabels the secondary pair: `inside_temperature_2` | ||
| # actually contains the outside reading and `outside_temperature_2` the | ||
| # inside one. On models where the primary fields are populated we use | ||
| # them; otherwise we fall back to the swapped secondary. Remove this | ||
| # workaround once upstream fixes the field labeling: | ||
| # https://github.com/prana-dev-official/prana-local-api | ||
| PranaSensorEntityDescription( | ||
| key=PranaSensorType.INSIDE_TEMPERATURE, | ||
| translation_key="inside_temperature", | ||
| value_fn=lambda coord: coord.data.inside_temperature, | ||
| native_unit_of_measurement=UnitOfTemperature.CELSIUS, | ||
| device_class=SensorDeviceClass.TEMPERATURE, | ||
| ), | ||
| PranaSensorEntityDescription( | ||
| key=PranaSensorType.INSIDE_TEMPERATURE_2, | ||
| translation_key="inside_temperature_2", | ||
| value_fn=lambda coord: coord.data.inside_temperature_2, | ||
| value_fn=lambda coord: ( | ||
| coord.data.inside_temperature | ||
| if coord.data.inside_temperature is not None | ||
| else coord.data.outside_temperature_2 | ||
| ), | ||
| native_unit_of_measurement=UnitOfTemperature.CELSIUS, | ||
| device_class=SensorDeviceClass.TEMPERATURE, | ||
| ), | ||
| PranaSensorEntityDescription( | ||
| key=PranaSensorType.OUTSIDE_TEMPERATURE, | ||
| translation_key="outside_temperature", | ||
| value_fn=lambda coord: coord.data.outside_temperature, | ||
| native_unit_of_measurement=UnitOfTemperature.CELSIUS, | ||
| device_class=SensorDeviceClass.TEMPERATURE, | ||
| ), | ||
| PranaSensorEntityDescription( | ||
| key=PranaSensorType.OUTSIDE_TEMPERATURE_2, | ||
| translation_key="outside_temperature_2", | ||
| value_fn=lambda coord: coord.data.outside_temperature_2, | ||
| value_fn=lambda coord: ( | ||
| coord.data.outside_temperature | ||
| if coord.data.outside_temperature is not None | ||
| else coord.data.inside_temperature_2 | ||
| ), | ||
| native_unit_of_measurement=UnitOfTemperature.CELSIUS, | ||
| device_class=SensorDeviceClass.TEMPERATURE, | ||
| ), |
There was a problem hiding this comment.
Update the sensor snapshots (or stop using snapshot_platform) to match the new set of exposed temperature sensors; the existing test suite relies on Syrupy snapshots and removing them will break CI.
There was a problem hiding this comment.
Hello @LucaTheHacker,
When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).
The commits that are missing a linked GitHub account are the following:
20117ee9971c2b93a9b159e34069e340cfce7306- This commit has something that looks like an email address (crostino-lunghezze0g@icloud.com). Maybe try linking that to GitHub?.
Unfortunately, we are unable to accept this pull request until this situation is corrected.
Here are your options:
-
If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.
-
If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.
- If you only made a single commit you should be able to run
(substituting "Author Name" and "
git commit --amend --author="Author Name <email@address.com>"email@address.com" for your actual information) to set the authorship information. - If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
- You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
- You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
- Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.
- If you only made a single commit you should be able to run
We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.
Thanks, I look forward to checking this PR again soon! ❤️
There was a problem hiding this comment.
It seems you haven't yet signed a CLA. Please do so here.
Once you do that we will be able to review and accept this pull request.
Thanks!
There was a problem hiding this comment.
Hello @LucaTheHacker,
When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).
The commits that are missing a linked GitHub account are the following:
7aa687b09f1d6f719311000cce435000cc73bd10- No email found attached to the commit.
Unfortunately, we are unable to accept this pull request until this situation is corrected.
Here are your options:
-
If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.
-
If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.
- If you only made a single commit you should be able to run
(substituting "Author Name" and "
git commit --amend --author="Author Name <email@address.com>"email@address.com" for your actual information) to set the authorship information. - If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
- You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
- You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
- Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.
- If you only made a single commit you should be able to run
We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.
Thanks, I look forward to checking this PR again soon! ❤️
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
homeassistant/components/prana/sensor.py:104
- Add/update the Prana sensor snapshot file to reflect the removal of the *_temperature_2 entities (the snapshot test still exists in
tests/components/prana/test_sensor.py, buttests/components/prana/snapshots/test_sensor.ambrwas removed).
# Devices only have two physical probes (one inside, one outside), but
# the upstream library mislabels the secondary pair: `inside_temperature_2`
# actually contains the outside reading and `outside_temperature_2` the
# inside one. On models where the primary fields are populated we use
# them; otherwise we fall back to the swapped secondary. Remove this
# workaround once upstream fixes the field labeling:
# https://github.com/prana-dev-official/prana-local-api
PranaSensorEntityDescription(
key=PranaSensorType.INSIDE_TEMPERATURE,
translation_key="inside_temperature",
value_fn=lambda coord: (
coord.data.inside_temperature
if coord.data.inside_temperature is not None
else coord.data.outside_temperature_2
),
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
),
PranaSensorEntityDescription(
key=PranaSensorType.OUTSIDE_TEMPERATURE,
translation_key="outside_temperature",
value_fn=lambda coord: (
coord.data.outside_temperature
if coord.data.outside_temperature is not None
else coord.data.inside_temperature_2
),
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
),
)
| """Test the Prana switches snapshot.""" | ||
| with patch("homeassistant.components.prana.PLATFORMS", [Platform.SWITCH]): | ||
| await async_init_integration(hass, mock_config_entry) | ||
|
|
||
| await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) | ||
|
|
There was a problem hiding this comment.
Add updated snapshot files for the switch platform tests (the snapshot-based test_switches is still present but tests/components/prana/snapshots/test_switch.ambr was removed).
| """Switch on/off calls set_switch with the corresponding key.""" | ||
| await async_init_integration(hass, mock_config_entry) | ||
|
|
||
| entries = er.async_entries_for_config_entry( | ||
| entity_registry, mock_config_entry.entry_id | ||
| ) | ||
| assert entries | ||
| target = f"switch.prana_recuperator{entity_suffix}" | ||
| target = f"switch.prana_recuperator_{switch_key}" | ||
|
|
There was a problem hiding this comment.
Resolve the switch entity_id via the entity registry (or update the expected entity_id), since the translated name was changed to "Winter mode" which will likely generate switch.prana_recuperator_winter_mode rather than switch.prana_recuperator_winter in a fresh registry.
| async def test_fans( | ||
| hass: HomeAssistant, | ||
| mock_prana_api: AsyncMock, | ||
| mock_config_entry: MockConfigEntry, | ||
| entity_registry: er.EntityRegistry, | ||
| type_key: str, | ||
| is_bound_mode: bool, | ||
| ) -> tuple[str, Any]: | ||
| """Set up a Prana fan entity for service tests.""" | ||
| mock_prana_api.get_state.return_value.bound = is_bound_mode | ||
| fan_mock_state = getattr( | ||
| mock_prana_api.get_state.return_value, | ||
| "bounded" if is_bound_mode else type_key, | ||
| ) | ||
|
|
||
| await async_init_integration(hass, mock_config_entry) | ||
|
|
||
| unique_id = f"{mock_config_entry.unique_id}_{type_key}" | ||
| target = entity_registry.async_get_entity_id(FAN_DOMAIN, "prana", unique_id) | ||
|
|
||
| assert target, f"Entity with unique_id {unique_id} not found" | ||
| mock_prana_api: MagicMock, | ||
| snapshot: SnapshotAssertion, | ||
| ) -> None: | ||
| """Test the Prana fans snapshot (linked model, default fixture).""" | ||
| with patch("homeassistant.components.prana.PLATFORMS", [Platform.FAN]): | ||
| await async_init_integration(hass, mock_config_entry) | ||
|
|
||
| return target, fan_mock_state | ||
| await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) | ||
|
|
There was a problem hiding this comment.
Add updated snapshot files for the fan platform tests (the snapshot-based test_fans is still present but tests/components/prana/snapshots/test_fan.ambr was removed).
Breaking change
Given some changes in the internal scheme it may be necessary to delete and re-create all the entities.
Proposed change
Currently the Prana Integration is not really similar to other fan implementations on HA, given this I have modified a bunch of behaviors to make it more usable and natural, along with fixing naming schemes for outside and inside temperature sensors that do not work properly due to Prana API.
I believe these changes make up for a good improvement in User Experience.
Type of change
Additional information
AI disclaimer, I have used Claude Code with Opus 4.7 to write this PR. Given the very small integration and the ability to directly test everything by hand, I'm quite sure everything is correct and should not break.
Given that the upstream API from prana appears to return improper data, such as "outside_temperature_2" instead of "inside_temperature", I have added some logic to automatically fix naming. Once Prana fixes their API, that code will not be necessary anymore.
Changes:
fan.py — restructured fan exposition
switch.py — junk drawer → two real toggles
sensor.py — mislabeled field workaround
Exposes only inside_temperature and outside_temperature.
Each has a fallback for devices where the primary field is None and the real data lives in the swap-labeled secondary (coord.data.outside_temperature_2 for inside, coord.data.inside_temperature_2
for outside). Comment flags this as a library workaround with link to upstream.
Dropped the _2 entities (they were the same two sensors with swapped labels, not extra data).
This PR fixes or closes issue: fixes #
This PR is related to issue:
Link to documentation pull request:
Link to developer documentation pull request:
Link to frontend pull request:
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: