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

[breaking change] Combine supported fan modes & custom fan modes #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vermi0ffh
Copy link

@vermi0ffh vermi0ffh commented Jan 22, 2025

This PR allow the integration to have more "supported fan modes". This allow other integrations to use those fan modes.
For example versatile thermostat can use supported fan modes when the AC don't see the right temperature, to mix air.

I had some conflicts in the process, so I renamed some enum values.

WARNING ! It's a breaking change for people using fan speed in automations !

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced fan mode support with new standard fan levels: Low, Medium, and High
    • Improved fan mode naming for better clarity
  • Improvements

    • Simplified fan level handling
    • Updated fan mode constants to provide more descriptive labels
  • Changes

    • Removed some custom fan levels
    • Renamed existing fan mode constants for better readability

Copy link

coderabbitai bot commented Jan 22, 2025

Walkthrough

The pull request introduces comprehensive changes to the Toshiba climate control system's fan mode handling. The modifications involve renaming and restructuring fan mode constants across multiple files, simplifying the fan level definitions, and updating the associated logic for processing fan modes. The changes aim to provide clearer semantics for fan levels and modes, removing redundant custom fan levels and introducing more standardized fan mode representations.

Changes

File Change Summary
components/toshiba_suzumi/toshiba_climate_mode.h - Removed CUSTOM_FAN_LEVEL_1 and CUSTOM_FAN_LEVEL_3 constants
- Updated CUSTOM_FAN_LEVEL_2 to "Low-Medium"
- Updated CUSTOM_FAN_LEVEL_4 to "Medium-High"
- Renamed fan mode enum values: FANMODE_1FAN_LOW, FANMODE_3FAN_MEDIUM, FANMODE_5FAN_HIGH
- Renamed AUTO to FAN_AUTO
components/toshiba_suzumi/toshiba_climate_mode.cpp - Simplified StringToFanLevel function by removing checks for removed fan levels
- Updated IntToCustomFanMode to handle new fan mode enum values
components/toshiba_suzumi/toshiba_climate.cpp - Updated fan mode handling in parseResponse and control methods
- Modified traits method to include new fan modes
- Adjusted logging statements for new fan mode constants

Sequence Diagram

sequenceDiagram
    participant User
    participant ClimateControl
    participant ToshibaClimateUart

    User->>ClimateControl: Set Fan Mode
    ClimateControl->>ToshibaClimateUart: sendCmd(FanMode)
    ToshibaClimateUart-->>ClimateControl: Confirm Mode Set
    ClimateControl-->>User: Fan Mode Updated
Loading

Poem

🌬️ Whispers of wind, fan modes anew,
From custom levels to clarity true,
Low, Medium, High - no more confusion's brew,
A climate dance with modes so sleek and few,
Toshiba's breeze now sings a fresher view! 🍃

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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 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

@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 comments (1)
components/toshiba_suzumi/toshiba_climate.cpp (1)

Clean up remaining legacy fan mode enum values

The fan mode implementation is mostly consistent, but there are still legacy enum values in the code:

  • components/toshiba_suzumi/toshiba_climate_mode.h: Remove unused FANMODE_2 and FANMODE_4 enum values as they're not referenced in the implementation.

The FAN_AUTO = 65 value and all other fan mode functionality is implemented correctly and consistently.

🔗 Analysis chain

Line range hint 1-1: Verify all fan mode references in the codebase.

Since this is a breaking change, let's verify that all fan mode references have been updated consistently.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to old fan mode names
echo "Searching for old fan mode references..."
rg -i "fanmode_[135]|auto.*=.*65|custom_fan_level_[13]" --type cpp

# Search for potential fan mode usage in configuration files
echo "Searching for fan mode usage in configuration files..."
rg -i "fan_mode|fan_level" --type yaml

Length of output: 384


Script:

#!/bin/bash
# Get context around FAN_AUTO definition
echo "Checking FAN_AUTO context..."
rg -B 5 -A 5 "FAN_AUTO.*=.*65" components/toshiba_suzumi/toshiba_climate_mode.h

# Search for fan mode related enums and function calls
echo "Checking fan mode related code..."
ast-grep --pattern 'enum $_ {
  $$$
  FAN_$$$
  $$$
}'

echo "Checking fan mode function calls..."
rg -B 2 -A 2 "set_fan_mode|get_fan_mode" --type cpp

Length of output: 4958

🧹 Nitpick comments (1)
components/toshiba_suzumi/toshiba_climate_mode.h (1)

31-37: Improve enum naming consistency.

While the renaming of fan modes improves clarity, consider these suggestions:

  1. Rename FANMODE_2 to FAN_LOW_MEDIUM for consistency with the string constant
  2. Rename FANMODE_4 to FAN_MEDIUM_HIGH for consistency with the string constant
 enum class FAN {
   FAN_QUIET = 49,
   FAN_LOW = 50,
-  FANMODE_2 = 51,
+  FAN_LOW_MEDIUM = 51,
   FAN_MEDIUM = 52,
-  FANMODE_4 = 53,
+  FAN_MEDIUM_HIGH = 53,
   FAN_HIGH = 54,
   FAN_AUTO = 65
 };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 74eee6e and 4d71d57.

📒 Files selected for processing (3)
  • components/toshiba_suzumi/toshiba_climate.cpp (3 hunks)
  • components/toshiba_suzumi/toshiba_climate_mode.cpp (1 hunks)
  • components/toshiba_suzumi/toshiba_climate_mode.h (2 hunks)
🔇 Additional comments (4)
components/toshiba_suzumi/toshiba_climate_mode.cpp (1)

46-52: LGTM! Functions correctly handle the new fan mode structure.

The implementation properly handles the conversion between string representations and fan modes, with appropriate error handling.

components/toshiba_suzumi/toshiba_climate.cpp (3)

229-243: LGTM! Clear and consistent fan mode handling in parseResponse.

The implementation properly handles all fan modes with clear logging.


366-388: LGTM! Comprehensive fan mode control implementation.

The control function properly handles all fan modes with appropriate logging and state management.


425-432: LGTM! Complete fan mode support in traits.

The traits properly expose all available fan modes, both standard and custom.

Comment on lines +10 to +11
static const std::string &CUSTOM_FAN_LEVEL_2 = "Low-Medium";
static const std::string &CUSTOM_FAN_LEVEL_4 = "Medium-High";
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Breaking change: Document fan level changes in README.

The removal of CUSTOM_FAN_LEVEL_1 and CUSTOM_FAN_LEVEL_3, and renaming of remaining levels improves clarity but breaks existing configurations.

Would you like me to help draft documentation explaining the migration path from old fan levels to new ones?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant