Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying solution for Core issue #132479 #661

Merged
merged 32 commits into from
Dec 8, 2024
Merged

Trying solution for Core issue #132479 #661

merged 32 commits into from
Dec 8, 2024

Conversation

bouwew
Copy link
Contributor

@bouwew bouwew commented Dec 7, 2024

All changes:

  • Connect cooling_enabled binary_sensor directly to self._cooling_enabled
  • Add cooling_enabled binary_sensor for Adam where missing
  • Issue #132479 probably results from the fact that self._cooling_enabled is, in __init__.py, linked to the binary_sensor cooling_enabled. When this one is not representing self._cooling_enabled but the xml-key cooling_enabled, errors might occur.

Summary by CodeRabbit

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new binary sensor, cooling_enabled, to indicate the cooling functionality for specific devices.
  • Tests

    • Enhanced test coverage for cooling functionalities in both the Adam and Anna modules.
    • Added new test cases to validate the state of cooling features during transitions between heating and cooling modes.
  • Chores

    • Updated version number to v1.6.3 in the project configuration.
    • Revised changelog to document the implementation of cooling-related fixes.

These updates improve the overall functionality and reliability of the cooling features within the system.

Copy link
Contributor

coderabbitai bot commented Dec 7, 2024

Walkthrough

The changes in this pull request introduce a new binary sensor, cooling_enabled, set to true for a specific device across various JSON files and classes. This addition signifies that the cooling functionality is now enabled for the device identified by the ID 0ca13e8176204ca7bf6f09de59f81c83. The modifications also include updates to several methods within the plugwise module to enhance the handling of cooling states, while maintaining the overall structure and logic of the existing code.

Changes

File Path Change Summary
fixtures/adam_heatpump_cooling/all_data.json Added new binary sensor "cooling_enabled": true for device ID 0ca13e8176204ca7bf6f09de59f81c83.
fixtures/adam_onoff_cooling_fake_firmware/all_data.json Added new binary sensor "cooling_enabled": true for device ID 0ca13e8176204ca7bf6f09de59f81c83.
plugwise/data.py Updated _get_adam_data method to include cooling_enabled in the entity data for heater_central devices.
plugwise/helper.py Modified _cooling_enabled assignment to update data["binary_sensors"]["cooling_enabled"].
plugwise/smile.py Introduced _cooling_enabled parameter in SmileAPI constructor and simplified logic in async_update.
tests/data/adam/adam_heatpump_cooling.json Added new binary sensor "cooling_enabled": true for device ID 0ca13e8176204ca7bf6f09de59f81c83.
tests/data/adam/adam_onoff_cooling_fake_firmware.json Added new binary sensor "cooling_enabled": true for entity ID 0ca13e8176204ca7bf6f09de59f81c83.
tests/data/anna/anna_elga_2_cooling_UPDATED_DATA.json Added new entities for Central Heater, Thermostat, and Gateway with detailed attributes.
tests/test_adam.py Enhanced test coverage for cooling functionalities in TestPlugwiseAdam.
tests/test_anna.py Added new test case for seasonal transition from cooling to heating; updated existing tests for better error handling.
tests/test_init.py Updated tinker_thermostat_temp and tinker_thermostat methods to include fail_cooling parameter.
CHANGELOG.md Added new version entry v1.6.3 documenting cooling-related fixes.
pyproject.toml Updated version from 1.6.2 to 1.6.3.
.github/workflows/verify.yml Updated Python version from "3.13" to "3.13.0" in workflow jobs.

Possibly related PRs

Suggested labels

enhancement, dependencies, python

Suggested reviewers

  • CoMPaTech

🐇 In the garden where cool breezes play,
A new sensor joins, brightening the day.
With cooling_enabled, the heat's kept at bay,
Hopping along, we celebrate this way!
🌼 Let the devices dance, in their cooling ballet! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 66e3ab2 and 54ef0ce.

📒 Files selected for processing (1)
  • pyproject.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pyproject.toml

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

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

🧹 Outside diff range and nitpick comments (2)
tests/data/anna/anna_elga_2_cooling_UPDATED_DATA.json (1)

60-62: Consider documenting cooling threshold parameters.

The cooling parameters would benefit from documentation explaining:

  • The significance of the 26.0°C activation temperature
  • How the 3.0°C deactivation threshold is applied
plugwise/helper.py (1)

801-801: Consider splitting the state assignment for better readability.

While the current implementation is correct, consider splitting the state assignment for better clarity:

-            self._cooling_enabled = data["binary_sensors"]["cooling_enabled"] = data["elga_status_code"] in (8, 9)
+            cooling_enabled = data["elga_status_code"] in (8, 9)
+            self._cooling_enabled = cooling_enabled
+            data["binary_sensors"]["cooling_enabled"] = cooling_enabled
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b42310d and 161f5db.

📒 Files selected for processing (12)
  • fixtures/adam_heatpump_cooling/all_data.json (1 hunks)
  • fixtures/adam_onoff_cooling_fake_firmware/all_data.json (1 hunks)
  • plugwise/__init__.py (2 hunks)
  • plugwise/data.py (2 hunks)
  • plugwise/helper.py (2 hunks)
  • plugwise/smile.py (3 hunks)
  • tests/data/adam/adam_heatpump_cooling.json (1 hunks)
  • tests/data/adam/adam_onoff_cooling_fake_firmware.json (1 hunks)
  • tests/data/anna/anna_elga_2_cooling_UPDATED_DATA.json (1 hunks)
  • tests/test_adam.py (1 hunks)
  • tests/test_anna.py (1 hunks)
  • tests/test_init.py (1 hunks)
🔇 Additional comments (14)
tests/data/adam/adam_onoff_cooling_fake_firmware.json (1)

5-5: LGTM! States are logically consistent.

The addition of cooling_enabled: true aligns correctly with:

  • cooling_state: true
  • heating_state: false
  • Gateway's select_regulation_mode: "cooling"
tests/data/anna/anna_elga_2_cooling_UPDATED_DATA.json (1)

6-12: LGTM! Binary sensor states are logically consistent.

The states correctly reflect a heating scenario:

  • cooling_enabled: false aligns with cooling_state: false
  • heating_state: true is appropriate when cooling is disabled
fixtures/adam_onoff_cooling_fake_firmware/all_data.json (1)

5-5: LGTM! Cooling configuration is consistent across all levels.

The addition of cooling_enabled: true is properly supported by:

  • Device level: cooling_state: true and heating_state: false
  • Gateway level: cooling_present: true and appropriate regulation modes
plugwise/data.py (1)

228-229: LGTM: Clean implementation of cooling_enabled binary sensor.

The implementation correctly adds the cooling_enabled binary sensor for heater_central devices when cooling is present, with proper condition checks and documentation.

Also applies to: 240-244

tests/test_adam.py (1)

323-324: LGTM: Good test coverage for cooling functionality.

The added assertions properly validate both the presence and enabled state of the cooling functionality.

plugwise/__init__.py (2)

68-68: LGTM: Proper initialization of cooling_enabled flag.

The _cooling_enabled attribute is correctly initialized as False by default and follows the established pattern of boolean flags in the class.


134-135: LGTM: Clean addition of cooling parameters to SmileAPI.

The cooling-related parameters are properly passed to SmileAPI constructor while maintaining the existing structure and not affecting the legacy API path.

plugwise/smile.py (2)

Line range hint 52-75: LGTM: Constructor parameter addition is well-implemented

The addition of _cooling_enabled parameter to the constructor is clean and follows existing patterns.


135-136: LGTM: Improved error handling clarity

The simplified error handling with a clear comment improves code maintainability.

tests/test_anna.py (1)

410-422: LGTM: Well-structured test for seasonal transition

The test case effectively simulates and validates the transition from cooling to heating mode with appropriate assertions.

tests/data/adam/adam_heatpump_cooling.json (1)

46-46: LGTM: Clean addition of cooling_enabled sensor

The addition of the cooling_enabled binary sensor is well-structured and maintains JSON format consistency.

fixtures/adam_heatpump_cooling/all_data.json (1)

46-46: LGTM! The addition of cooling_enabled binary sensor is consistent with the device's cooling capabilities.

The new binary sensor aligns with:

  • The device's "Generic heater/cooler" model type
  • The gateway's cooling support (cooling_present: true)
  • The existing cooling-related sensors in the device
tests/test_init.py (1)

649-649: LGTM! Enhanced test observability for cooling functionality.

The added logging statement improves debugging capabilities by exposing the cooling enabled state during test execution.

plugwise/helper.py (1)

250-250: LGTM! Improved type safety with bool annotation.

The explicit type annotation enhances code maintainability and helps catch type-related errors early.

@bouwew bouwew changed the title Just for testing now Trying solution for Core issue #132479 Dec 7, 2024
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: 1

🧹 Outside diff range and nitpick comments (1)
pyproject.toml (1)

Line range hint 25-25: Consider relaxing the Python version requirement

The project requires Python >=3.12.0, which is quite recent. This might limit adoption as many users may still be on Python 3.11 or earlier. Consider if Python 3.11 compatibility can be maintained unless there are specific 3.12 features being used.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c2deae7 and 4bb7b95.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • pyproject.toml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

pyproject.toml Outdated Show resolved Hide resolved
@bouwew bouwew force-pushed the test-elga_2 branch 2 times, most recently from ecca135 to e654a08 Compare December 7, 2024 12:45
Copy link

codecov bot commented Dec 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (b42310d) to head (54ef0ce).
Report is 33 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #661   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines         3415      3436   +21     
=========================================
+ Hits          3415      3436   +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bouwew bouwew marked this pull request as ready for review December 7, 2024 13:06
@bouwew bouwew requested a review from a team as a code owner December 7, 2024 13:06
@bouwew bouwew added the bug Something isn't working label Dec 7, 2024
@bouwew bouwew requested a review from CoMPaTech December 7, 2024 13:19
@bouwew
Copy link
Contributor Author

bouwew commented Dec 7, 2024

Will set to v1.6.3 when approved.

"""
if self.smile(ADAM):
if entity["dev_class"] == "heater_central":
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should 'match/case' this, but at least just return before the match against gateway (as that wouldn't be processed e.g. there is nothing more to do once heater central is done)?

Copy link

sonarqubecloud bot commented Dec 8, 2024

@bouwew bouwew merged commit d8336a3 into main Dec 8, 2024
20 checks passed
@bouwew bouwew deleted the test-elga_2 branch December 8, 2024 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants