Skip to content

Conversation

@bouwew
Copy link
Contributor

@bouwew bouwew commented Jul 15, 2025

Should fix issue #897

Summary by CodeRabbit

  • Tests
    • Updated climate entity tests to verify correct reporting of the "heat_cool" mode.
    • Added schedule-related fields to multiple device test fixtures and snapshots.
    • Removed obsolete regulation mode selection from device snapshots.
  • Bug Fixes
    • Improved entity creation logic to prevent instantiation with empty option values.
    • Enhanced schedule availability checks to avoid errors when schedule data is missing.
  • Chores
    • Updated Plugwise package dependency to version 1.7.8.
    • Incremented integration version to 0.57.6.

@bouwew bouwew requested a review from CoMPaTech July 15, 2025 09:45
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 15, 2025

Walkthrough

The test for the Plugwise Anna climate component was updated to set the mocked device's climate mode to "heat_cool" and adjust assertions to expect the corresponding HVACMode.HEAT_COOL state and supported modes. The Plugwise manifest dependency was changed to require version 1.7.8. The entity setup for select entities was refined to require truthy options. Several fixture JSON files were updated to add new keys for schedules or modify existing keys. The climate component's schedule presence check was made safer using .get(). No changes were made to public or exported entities.

Changes

File(s) Change Summary
tests/components/plugwise/test_climate.py Updated mocked device data to use "climate_mode": "heat_cool" and adjusted assertions for new HVAC mode.
custom_components/plugwise/manifest.json Changed plugwise package requirement to version 1.7.8; incremented integration version to 0.57.6.
custom_components/plugwise/select.py Refined condition to add select entities only if options key value is truthy; updated return type of current_option.
custom_components/plugwise/climate.py Changed schedule presence check to use .get() method for safer access.
tests/components/plugwise/fixtures/legacy_anna/data.json Added "available_schedules": [] and "select_schedule": null fields to thermostat device.
tests/components/plugwise/fixtures/m_adam_jip/data.json Added "available_schedules": [] and "select_schedule": null to multiple climate device entries.
tests/components/plugwise/fixtures/m_adam_multiple_devices_per_zone/data.json Added schedule fields to one device; removed "select_regulation_mode": "heating" from another device.
tests/components/plugwise/snapshots/test_diagnostics.ambr Added schedule keys to one device snapshot; removed "select_regulation_mode" key from another device snapshot.
CHANGELOG.md Added changelog entry for version 0.57.6 documenting fix for issue #897 with plugwise dependency update.
pyproject.toml Incremented project version from 0.57.5 to 0.57.6.

Possibly related PRs

Suggested reviewers

  • CoMPaTech

Poem

In the land of test and code,
A climate mode did shift its load.
From heat alone to heat and cool,
The rabbits cheer, “This change is cool!”
With every hop, the tests align,
Plugwise Anna’s doing fine!
🐇❄️🔥


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d8378c and fa46a82.

📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • custom_components/plugwise/climate.py (1 hunks)
  • custom_components/plugwise/manifest.json (1 hunks)
  • pyproject.toml (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • CHANGELOG.md
  • custom_components/plugwise/manifest.json
  • pyproject.toml
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: bouwew
PR: plugwise/plugwise-beta#671
File: custom_components/plugwise/switch.py:82-83
Timestamp: 2024-10-08T15:35:25.180Z
Learning: User bouwew prefers to ignore exception handling suggestions for the `pw-beta` branch in the `custom_components/plugwise/switch.py` file.
Learnt from: bouwew
PR: plugwise/plugwise-beta#671
File: custom_components/plugwise/switch.py:82-83
Timestamp: 2024-06-22T08:05:56.791Z
Learning: User bouwew prefers to ignore exception handling suggestions for the `pw-beta` branch in the `custom_components/plugwise/switch.py` file.
Learnt from: bouwew
PR: plugwise/plugwise-beta#734
File: tests/components/plugwise/test_config_flow.py:58-58
Timestamp: 2024-09-27T09:48:30.890Z
Learning: In `tests/components/plugwise/test_config_flow.py`, the versions are mocked firmware versions for testing purposes and do not need to match the software version in `manifest.json`.
Learnt from: bouwew
PR: plugwise/plugwise-beta#734
File: tests/components/plugwise/test_config_flow.py:58-58
Timestamp: 2024-10-08T15:35:25.180Z
Learning: In `tests/components/plugwise/test_config_flow.py`, the versions are mocked firmware versions for testing purposes and do not need to match the software version in `manifest.json`.
Learnt from: bouwew
PR: plugwise/plugwise-beta#793
File: custom_components/plugwise/manifest.json:10-11
Timestamp: 2024-12-12T19:48:34.652Z
Learning: In the Plugwise integration, temporary use of alpha versions from test repositories is acceptable for testing purposes.
Learnt from: CoMPaTech
PR: plugwise/plugwise-beta#0
File: :0-0
Timestamp: 2025-01-25T20:42:24.862Z
Learning: The linting rules in plugwise-beta have been updated to use TC001/TC002/TC003 instead of TCH001/TCH002/TCH003 for type-checking related rules.
🧬 Code Graph Analysis (1)
custom_components/plugwise/climate.py (1)
custom_components/plugwise/entity.py (1)
  • device (91-93)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Prepare
🔇 Additional comments (1)
custom_components/plugwise/climate.py (1)

222-222: LGTM! Proper handling of schedule availability.

The change from checking key existence to checking truthiness is semantically correct. This ensures that HVACMode.AUTO is only available when there are actual schedules present, not just when the key exists with a falsy value (like None or an empty list).

This aligns perfectly with the PR objective of handling the scenario where the backend sets available_schedules to None after removing the last schedule.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-897

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@CoMPaTech CoMPaTech linked an issue Jul 15, 2025 that may be closed by this pull request
Copy link
Member

@CoMPaTech CoMPaTech left a comment

Choose a reason for hiding this comment

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

Still not sure what intent we have here to test, but that would ensure the assert works :) (+needs upstreaming)

@bouwew
Copy link
Contributor Author

bouwew commented Jul 15, 2025

Still not sure what intent we have here to test, but that would ensure the assert works :) (+needs upstreaming)

This covers removing the (last remaining) schedule from the Plugwise App.
The backend will pick this up and set available_schedules to None, from the top of my head :)

@CoMPaTech CoMPaTech added bug Something isn't working needs_upstreaming Things that are here in -beta but must be upstreamed to HA-core labels Jul 15, 2025
Copy link
Member

@CoMPaTech CoMPaTech left a comment

Choose a reason for hiding this comment

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

Should have been a comment - and still has the assert failing for auto != heatcool

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Error while testing for Development HA-core:

⚠️ Warning: Incompatible while testing against dev HA-core.
✔️ Success: No problem with testing against released HA-core.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Error while testing for Development HA-core:

⚠️ Warning: Incompatible while testing against dev HA-core.
✔️ Success: No problem with testing against released HA-core.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
custom_components/plugwise/select.py (1)

100-100: Logic change correctly handles empty or null options.

The addition of the truthiness check and device[description.options_key] is appropriate for preventing select entities from being created when the options list is empty or None. This aligns with the PR objective of handling cases where the last remaining schedule is removed and available_schedules is set to None.

Consider applying the static analysis suggestion to use dict.get for cleaner code:

-                if description.options_key in device and device[description.options_key]:
+                if device.get(description.options_key):

This would achieve the same result more concisely since dict.get returns None for missing keys, which is falsy.

custom_components/plugwise/manifest.json (1)

10-12: Dependency updated to pre-release version for testing.

The update to use pre-release version 1.7.8a2 from the test PyPI URL is appropriate for testing the fix for issue #897. This aligns with the project's established practice of using alpha versions from test repositories for testing purposes.

Remember to update this to a stable version once the fix is finalized and the package is published to the main PyPI repository.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6027c17 and d251e0d.

📒 Files selected for processing (5)
  • custom_components/plugwise/manifest.json (1 hunks)
  • custom_components/plugwise/select.py (1 hunks)
  • tests/components/plugwise/fixtures/legacy_anna/data.json (2 hunks)
  • tests/components/plugwise/fixtures/m_adam_jip/data.json (4 hunks)
  • tests/components/plugwise/fixtures/m_adam_multiple_devices_per_zone/data.json (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • tests/components/plugwise/fixtures/legacy_anna/data.json
  • tests/components/plugwise/fixtures/m_adam_jip/data.json
  • tests/components/plugwise/fixtures/m_adam_multiple_devices_per_zone/data.json
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: bouwew
PR: plugwise/plugwise-beta#671
File: custom_components/plugwise/switch.py:82-83
Timestamp: 2024-06-22T08:05:56.791Z
Learning: User bouwew prefers to ignore exception handling suggestions for the `pw-beta` branch in the `custom_components/plugwise/switch.py` file.
Learnt from: bouwew
PR: plugwise/plugwise-beta#671
File: custom_components/plugwise/switch.py:82-83
Timestamp: 2024-10-08T15:35:25.180Z
Learning: User bouwew prefers to ignore exception handling suggestions for the `pw-beta` branch in the `custom_components/plugwise/switch.py` file.
Learnt from: bouwew
PR: plugwise/plugwise-beta#734
File: tests/components/plugwise/test_config_flow.py:58-58
Timestamp: 2024-10-08T15:35:25.180Z
Learning: In `tests/components/plugwise/test_config_flow.py`, the versions are mocked firmware versions for testing purposes and do not need to match the software version in `manifest.json`.
Learnt from: bouwew
PR: plugwise/plugwise-beta#734
File: tests/components/plugwise/test_config_flow.py:58-58
Timestamp: 2024-09-27T09:48:30.890Z
Learning: In `tests/components/plugwise/test_config_flow.py`, the versions are mocked firmware versions for testing purposes and do not need to match the software version in `manifest.json`.
Learnt from: bouwew
PR: plugwise/plugwise-beta#793
File: custom_components/plugwise/manifest.json:10-11
Timestamp: 2024-12-12T19:48:34.652Z
Learning: In the Plugwise integration, temporary use of alpha versions from test repositories is acceptable for testing purposes.
Learnt from: CoMPaTech
PR: plugwise/plugwise-beta#0
File: :0-0
Timestamp: 2025-01-25T20:42:24.862Z
Learning: The linting rules in plugwise-beta have been updated to use TC001/TC002/TC003 instead of TCH001/TCH002/TCH003 for type-checking related rules.
custom_components/plugwise/select.py (1)
Learnt from: CoMPaTech
PR: plugwise/plugwise-beta#0
File: :0-0
Timestamp: 2025-01-25T20:42:24.862Z
Learning: The linting rules in plugwise-beta have been updated to use TC001/TC002/TC003 instead of TCH001/TCH002/TCH003 for type-checking related rules.
custom_components/plugwise/manifest.json (5)
Learnt from: bouwew
PR: plugwise/plugwise-beta#734
File: tests/components/plugwise/test_config_flow.py:58-58
Timestamp: 2024-09-27T09:48:30.890Z
Learning: In `tests/components/plugwise/test_config_flow.py`, the versions are mocked firmware versions for testing purposes and do not need to match the software version in `manifest.json`.
Learnt from: bouwew
PR: plugwise/plugwise-beta#734
File: tests/components/plugwise/test_config_flow.py:58-58
Timestamp: 2024-10-08T15:35:25.180Z
Learning: In `tests/components/plugwise/test_config_flow.py`, the versions are mocked firmware versions for testing purposes and do not need to match the software version in `manifest.json`.
Learnt from: bouwew
PR: plugwise/plugwise-beta#793
File: custom_components/plugwise/manifest.json:10-11
Timestamp: 2024-12-12T19:48:34.652Z
Learning: In the Plugwise integration, temporary use of alpha versions from test repositories is acceptable for testing purposes.
Learnt from: CoMPaTech
PR: plugwise/plugwise-beta#0
File: :0-0
Timestamp: 2025-01-25T20:42:24.862Z
Learning: In the plugwise-beta project, `uv` package manager was removed from core-testing.sh in favor of pip due to issues it was causing.
Learnt from: CoMPaTech
PR: plugwise/plugwise-beta#0
File: :0-0
Timestamp: 2025-01-25T20:42:24.862Z
Learning: The linting rules in plugwise-beta have been updated to use TC001/TC002/TC003 instead of TCH001/TCH002/TCH003 for type-checking related rules.
🧬 Code Graph Analysis (1)
custom_components/plugwise/select.py (1)
custom_components/plugwise/entity.py (1)
  • device (91-93)
🪛 Ruff (0.12.2)
custom_components/plugwise/select.py

100-100: Unnecessary key check before dictionary access

Replace with dict.get

(RUF019)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Prepare

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Error while testing for Development HA-core:

⚠️ Warning: Incompatible while testing against dev HA-core.
✔️ Success: No problem with testing against released HA-core.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Error while testing for Development HA-core:

⚠️ Warning: Incompatible while testing against dev HA-core.
✔️ Success: No problem with testing against released HA-core.

@sonarqubecloud
Copy link

@bouwew bouwew marked this pull request as ready for review July 16, 2025 15:30
@bouwew bouwew requested a review from a team as a code owner July 16, 2025 15:30
@bouwew bouwew requested a review from CoMPaTech July 16, 2025 15:33
@bouwew bouwew merged commit de1892b into main Jul 16, 2025
13 checks passed
@bouwew bouwew deleted the fix-897 branch July 17, 2025 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working needs_upstreaming Things that are here in -beta but must be upstreamed to HA-core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TODO]: anna_heatpump intermittent issue during testing

3 participants