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

Add Matter fan platform #111212

Merged
merged 12 commits into from May 28, 2024
Merged

Add Matter fan platform #111212

merged 12 commits into from May 28, 2024

Conversation

lboue
Copy link
Contributor

@lboue lboue commented Feb 23, 2024

Proposed change

Add Fan platform to Matter integration.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

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

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 link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@lboue lboue requested a review from a team as a code owner February 23, 2024 17:39
home-assistant[bot]

This comment was marked as resolved.

@home-assistant

This comment was marked as resolved.

@home-assistant home-assistant bot marked this pull request as draft February 23, 2024 17:39
@home-assistant
Copy link

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

Code owner commands

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

@TheJulianJES TheJulianJES changed the title [Draft] Add Fan integration (Fan device) [Draft] Add Matter fan platform Feb 23, 2024
@MartinHjelmare MartinHjelmare changed the title [Draft] Add Matter fan platform Add Matter fan platform Feb 23, 2024
@lboue
Copy link
Contributor Author

lboue commented Feb 24, 2024

@balloob
Is there a tutorial that explains how to modify ha core locally to test adding a new device Matter type?

@balloob
Copy link
Member

balloob commented Feb 24, 2024

@lboue
Copy link
Contributor Author

lboue commented Mar 3, 2024

@balloob
I meant to add a live python file in matter directory, not to add a CICD test file.

Is it possible to access the homeassistant/components/matter directory from the web interface's file editor?
If not, does this require recompiling the entire ha core?

@marcelveldt
Copy link
Member

marcelveldt commented May 1, 2024

As discussed I'm working on completing this PR for you. Because of some unfortunate other issues that had higher prio this didn't make it into the may release of HA but it will 100% be in the next one. Thanks for the patience.

@lboue
Copy link
Contributor Author

lboue commented May 1, 2024

As discussed I'm working on completing this PR for you. Because of some unfortunate other issues that gad highe rprio this didn't make it into the may release of HA but it will 100% be in the next one. Thanks for the patience.

Thanks

lboue added 4 commits May 24, 2024 13:46
Init commit for MatterFan
Add Mock Fan device
Draft for testing Matter fan
Rebase from Matter switch (draft)
@marcelveldt marcelveldt dismissed home-assistant’s stale review May 27, 2024 16:54

PR refactored + docs PR added

@marcelveldt marcelveldt marked this pull request as ready for review May 27, 2024 16:54
@marcelveldt marcelveldt added this to the 2024.6.0b0 milestone May 27, 2024
homeassistant/components/matter/fan.py Outdated Show resolved Hide resolved
homeassistant/components/matter/fan.py Show resolved Hide resolved
homeassistant/components/matter/fan.py Show resolved Hide resolved
@frenck
Copy link
Member

frenck commented May 28, 2024

@coderabbitai review

Copy link

coderabbitai bot commented May 28, 2024

Walkthrough

The changes introduce Matter Fan platform support to Home Assistant, allowing users to control Matter-compatible fans. This includes adding a new MatterFan class with various control methods, updating the discovery mechanism to recognize Matter fans, and creating corresponding test cases.

Changes

Files/Paths Change Summary
homeassistant/components/matter/discovery.py Added import for FAN_SCHEMAS and updated Platform to include Platform.FAN with FAN_SCHEMAS.
homeassistant/components/matter/fan.py Introduced MatterFan class, methods for fan control, async_setup_entry, and DISCOVERY_SCHEMAS.
tests/components/matter/fixtures/air-purifier.json Added detailed node attributes for an air purifier device.
tests/components/matter/test_fan.py Added test cases for Matter Fan platform, including control of fan attributes and functionalities.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant HomeAssistant
    participant MatterFan
    participant MatterDevice

    User->>HomeAssistant: Turn on Fan
    HomeAssistant->>MatterFan: async_turn_on()
    MatterFan->>MatterDevice: Send Turn On Command
    MatterDevice-->>MatterFan: Acknowledge Turn On
    MatterFan-->>HomeAssistant: Update State to On
    HomeAssistant-->>User: Fan is On

    User->>HomeAssistant: Set Fan Speed to 50%
    HomeAssistant->>MatterFan: async_set_percentage(50)
    MatterFan->>MatterDevice: Send Speed Command (50%)
    MatterDevice-->>MatterFan: Acknowledge Speed Change
    MatterFan-->>HomeAssistant: Update Speed to 50%
    HomeAssistant-->>User: Fan Speed Set to 50%

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 full the 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

@frenck frenck merged commit f44dfe8 into home-assistant:dev May 28, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants