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

feat(b8): first implementation #225

Merged
merged 18 commits into from
Jul 30, 2024
Merged

feat(b8): first implementation #225

merged 18 commits into from
Jul 30, 2024

Conversation

rokam
Copy link
Contributor

@rokam rokam commented Jul 14, 2024

First implementation of B8 type of device (vaccum cleaner).

Summary by CodeRabbit

  • New Features

    • Introduced support for Midea B8 devices, including robust message processing and attribute management.
    • Added detailed enums for various statuses, modes, and error types related to Midea B8 devices.
    • Enhanced device interaction capabilities with specific methods for queries, message processing, and attribute settings.
  • Tests

    • Implemented a comprehensive suite of unit tests for validating the functionality of the Midea B8 device.

Copy link
Contributor

coderabbitai bot commented Jul 14, 2024

Walkthrough

The update enriches the functionality for Midea B8 devices, introducing a structured class hierarchy for device management, refined message processing, and improved attribute manipulation. It adds new enums for device attributes, work modes, statuses, and error types, enhancing communication and interaction with Midea B8 appliances throughout the system.

Changes

File Path Change Summary
midealocal/devices/b8/__init__.py Introduced MideaB8Device and MideaAppliance classes, enhancing device management with methods for querying and attribute setting.
midealocal/devices/b8/message.py Defined message handling classes like MessageB8Base, MessageQuery, and MessageSet, facilitating structured communication.
midealocal/devices/b8/const.py Created constants and enumerations for device attributes, work modes, statuses, and error types for structured access.
midealocal/message.py Added a new member X42 to the BodyType enumeration to expand message type capabilities.
tests/devices/b8/__init__.py Introduced a module for unit tests dedicated to Midea B8 device functionalities.
tests/devices/b8/device_b8_test.py Implemented a suite of unit tests for the MideaB8Device class, validating its methods and behaviors.

Poem

In circuits laid with care and might,
The Midea B8 takes flight,
With attributes and queries grand,
It listens, acts at our command.
Through messages it speaks so true,
A marvel built for me and you.
🌟✨


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

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

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.

@codecov-commenter
Copy link

codecov-commenter commented Jul 14, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 99.21569% with 2 lines in your changes missing coverage. Please review.

Project coverage is 37.55%. Comparing base (ad9f278) to head (0fcc21f).

Files Patch % Lines
midealocal/devices/b8/message.py 97.01% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #225      +/-   ##
==========================================
+ Coverage   35.34%   37.55%   +2.20%     
==========================================
  Files          81       84       +3     
  Lines        7191     7446     +255     
==========================================
+ Hits         2542     2796     +254     
- Misses       4649     4650       +1     

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

@midea-lan midea-lan deleted a comment from coderabbitai bot Jul 14, 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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 46196cb and deb41b5.

Files selected for processing (2)
  • midealocal/devices/b8/init.py (1 hunks)
  • midealocal/devices/b8/message.py (1 hunks)
Additional comments not posted (27)
midealocal/devices/b8/__init__.py (5)

22-50: LGTM!

The DeviceAttributes enum is well-defined and includes a comprehensive list of attributes for the Midea B8 device.


52-107: Ensure proper handling of customize parameter.

The customize parameter is marked with # noqa: ARG002, which indicates it is unused. Ensure that this parameter is intended to be unused or consider removing it if unnecessary.


109-112: LGTM!

The build_query method is straightforward and correctly constructs a query for the Midea B8 device.


131-132: LGTM!

The MideaAppliance class correctly inherits from MideaB8Device without adding new methods or attributes.


113-125: Ensure all attributes are correctly processed.

The process_message method processes messages and updates device attributes. Ensure that all attributes are correctly handled and consider adding unit tests to verify the functionality.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

midealocal/devices/b8/message.py (22)

14-35: LGTM!

The WorkStatus enum is well-defined and includes a comprehensive list of work statuses for the Midea B8 device.


37-42: LGTM!

The FunctionType enum is well-defined and includes a comprehensive list of function types for the Midea B8 device.


44-50: LGTM!

The ControlType enum is well-defined and includes a comprehensive list of control types for the Midea B8 device.


52-60: LGTM!

The Moviment enum is well-defined and includes a comprehensive list of movements for the Midea B8 device.


62-78: LGTM!

The CleanMode enum is well-defined and includes a comprehensive list of clean modes for the Midea B8 device.


80-88: LGTM!

The FanLevel enum is well-defined and includes a comprehensive list of fan levels for the Midea B8 device.


90-97: LGTM!

The WaterLevel enum is well-defined and includes a comprehensive list of water levels for the Midea B8 device.


99-105: LGTM!

The MopState enum is well-defined and includes a comprehensive list of mop states for the Midea B8 device.


107-112: LGTM!

The Speed enum is well-defined and includes a comprehensive list of speeds for the Midea B8 device.


114-121: LGTM!

The ErrorType enum is well-defined and includes a comprehensive list of error types for the Midea B8 device.


123-143: LGTM!

The ErrorCanFixDescription enum is well-defined and includes a comprehensive list of error descriptions for fixable errors in the Midea B8 device.


145-152: LGTM!

The ErrorRebootDescription enum is well-defined and includes a comprehensive list of error descriptions for errors requiring a reboot in the Midea B8 device.


154-162: LGTM!

The ErrorWarningDescription enum is well-defined and includes a comprehensive list of error descriptions for warning errors in the Midea B8 device.


164-168: LGTM!

The StatusType enum is well-defined and includes a comprehensive list of status types for the Midea B8 device.


170-186: LGTM!

The MessageB8Base class is well-defined and correctly initializes the message base for the Midea B8 device.


192-202: LGTM!

The MessageQuery class is well-defined and correctly initializes the query message for the Midea B8 device.


203-205: LGTM!

The _body property correctly returns the message body for the query message.


208-223: LGTM!

The MessageSet class is well-defined and correctly initializes the set message for the Midea B8 device.


224-237: Ensure correct data types in _body property.

The _body property returns a bytearray, but ensure that all elements in the bytearray are of the correct data type (e.g., integers).


292-305: LGTM!

The MessageB8Response class is well-defined and correctly initializes the response message for the Midea B8 device.


306-317: LGTM!

The parse_body method correctly parses the message body for the response message.


240-290: Ensure correct parsing of message body.

The MessageB8WorkStatusBody class parses various attributes from the message body. Ensure that all attributes are correctly parsed and consider adding unit tests to verify the functionality.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

midealocal/devices/b8/__init__.py Show resolved Hide resolved
midealocal/devices/b8/message.py Show resolved Hide resolved
@tufeikafei
Copy link

cool, thank you very much.
I will test it first.

@rokam
Copy link
Contributor Author

rokam commented Jul 22, 2024

cool, thank you very much. I will test it first.

There is still some job to be done.

@rokam rokam added breaking change A change that is not backwards compatible enhancement New feature or request and removed breaking change A change that is not backwards compatible labels Jul 25, 2024
@rokam rokam marked this pull request as ready for review July 29, 2024 17:04
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, codebase verification and nitpick comments (1)
midealocal/message.py (1)

41-41: The new X42 member of the BodyType enum is not being utilized in the codebase.

Please ensure that all necessary logic and tests are updated to handle the new X42 member appropriately.

  • No occurrences of BodyType.X42 were found in the codebase.
Analysis chain

LGTM! But verify the enum usage in the codebase.

The addition of the new member X42 to the BodyType enumeration is syntactically correct.

However, ensure that all usages of BodyType are updated to handle the new X42 member appropriately.


Let's correct the rg command and re-run the script to verify the usage of the BodyType enum in the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `BodyType` to ensure they handle the new `X42` member.

# Test: Search for the `BodyType` usage. Expect: Occurrences of `X42` being handled.
rg --type python -A 5 $'BodyType'

Length of output: 63


Script:

#!/bin/bash
# Description: Verify all usages of `BodyType` to ensure they handle the new `X42` member.

# Test: Search for the `BodyType` usage. Expect: Occurrences of `X42` being handled.
rg 'BodyType' --glob '*.py' -A 5

Length of output: 43468

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between deb41b5 and 02658f8.

Files selected for processing (6)
  • midealocal/devices/b8/init.py (1 hunks)
  • midealocal/devices/b8/const.py (1 hunks)
  • midealocal/devices/b8/message.py (1 hunks)
  • midealocal/message.py (1 hunks)
  • tests/devices/b8/init.py (1 hunks)
  • tests/devices/b8/device_b8_test.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • tests/devices/b8/init.py
Additional comments not posted (35)
midealocal/devices/b8/const.py (14)

6-33: LGTM!

The B8DeviceAttributes enum class is well-defined and consistent.


36-43: LGTM!

The B8WorkMode enum class is well-defined and consistent.


45-67: LGTM!

The B8WorkStatus enum class is well-defined and consistent.


69-75: LGTM!

The B8FunctionType enum class is well-defined and consistent.


77-83: LGTM!

The B8ControlType enum class is well-defined and consistent.


85-93: LGTM!

The B8Moviment enum class is well-defined and consistent.


95-111: LGTM!

The B8CleanMode enum class is well-defined and consistent.


113-121: LGTM!

The B8FanLevel enum class is well-defined and consistent.


123-130: LGTM!

The B8WaterLevel enum class is well-defined and consistent.


132-138: LGTM!

The B8MopState enum class is well-defined and consistent.


140-145: LGTM!

The B8Speed enum class is well-defined and consistent.


147-154: LGTM!

The B8ErrorType enum class is well-defined and consistent.


156-195: LGTM!

The B8ErrorCanFixDescription, B8ErrorRebootDescription, and B8ErrorWarningDescription enum classes are well-defined and consistent.


197-200: LGTM!

The B8StatusType enum class is well-defined and consistent.

midealocal/devices/b8/__init__.py (7)

36-88: LGTM!

The __init__ method is well-defined and consistent.


90-93: LGTM!

The build_query method is well-defined and consistent.


94-106: LGTM!

The process_message method is well-defined and consistent.


108-120: LGTM!

The _gen_set_msg_default_values method is well-defined and consistent.


122-133: LGTM!

The set_work_mode method is well-defined and consistent.


134-151: LGTM!

The set_attribute method is well-defined and consistent.


153-154: LGTM!

The MideaAppliance class is well-defined and consistent.

midealocal/devices/b8/message.py (6)

33-52: LGTM!

The MessageB8Base class is well-defined and consistent.


55-68: LGTM!

The MessageQuery class is well-defined and consistent.


71-100: LGTM!

The MessageSet class is well-defined and consistent.


103-123: LGTM!

The MessageSetCommand class is well-defined and consistent.


126-217: LGTM!

The MessageB8GenericBody class is well-defined and consistent.


239-245: LGTM!

The MessageB8WorkStatusBody class is well-defined and consistent.

tests/devices/b8/device_b8_test.py (8)

36-50: LGTM!

The _setup_device fixture correctly initializes the MideaB8Device instance for tests.


52-112: LGTM!

The test_initial_attributes function comprehensively checks the initial attributes of the MideaB8Device instance.


113-134: LGTM!

The test_set_attribute function correctly tests the set_attribute method using the patch object to mock send_message_v2.


135-144: LGTM!

The test_set_work_mode function correctly tests the set_work_mode method using the patch object to mock send_message_v2.


145-150: LGTM!

The test_build_query function correctly tests the build_query method to ensure it returns a list containing a single MessageQuery instance.


151-211: LGTM!

The test_query_response function correctly tests the process_message method to ensure it updates the device attributes based on the query response.


212-271: LGTM!

The test_notify_response function correctly tests the process_message method to ensure it updates the device attributes based on the notify response.


272-423: LGTM!

The test functions test_query_response_reboot_error, test_query_response_no_error, and test_unexpected_response correctly test the process_message method to ensure it updates the device attributes based on the different types of responses.

@rokam rokam requested a review from chemelli74 July 30, 2024 12:58
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 02658f8 and 0fcc21f.

Files selected for processing (1)
  • midealocal/devices/b8/message.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • midealocal/devices/b8/message.py

Copy link
Member

@chemelli74 chemelli74 left a comment

Choose a reason for hiding this comment

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

LGTM !

@rokam rokam merged commit 259e4f2 into main Jul 30, 2024
10 checks passed
@rokam rokam deleted the feature/b8-devicetype branch July 30, 2024 18:37
@rokam rokam mentioned this pull request Jul 30, 2024
rokam added a commit that referenced this pull request Jul 30, 2024
🤖 I have created a release *beep* *boop*
---


## [2.5.0](v2.4.0...v2.5.0)
(2024-07-30)


### Features

* **40:** add `precision_halves` customization
([#248](#248))
([8f5ec79](8f5ec79))
* **b8:** first implementation
([#225](#225))
([259e4f2](259e4f2))


### Bug Fixes

* `break` the loop when connected
([#244](#244))
([536f975](536f975))
* **ac:** correct attributes based on msg type
([#251](#251))
([fada9bc](fada9bc))
* **cloud:** fix email obfuscation
([#245](#245))
([ad9f278](ad9f278))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants