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 new vacuum state property and enum #2360

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gjohansson-ST
Copy link
Member

@gjohansson-ST gjohansson-ST commented Oct 13, 2024

Proposed change

Add new state property for vacuum.
Also new enum for return values
Core PR: home-assistant/core#126353

Type of change

  • Document existing features within Home Assistant
  • Document new or changing features which there is an existing pull request elsewhere
  • Spelling or grammatical corrections, or rewording for improved clarity
  • Changes to the backend of this documentation
  • Removed stale or deprecated documentation

Additional information

  • This PR fixes or closes issue: fixes #
  • Link to relevant existing code or pull request:

Summary by CodeRabbit

  • New Features

    • Introduced a new vacuum_state property for improved vacuum state management.
    • Updated documentation includes examples for implementing the new property.
  • Documentation

    • Clarified the deprecation of the state property and provided migration guidance.
    • Reformatted state values to use uppercase strings for consistency.

Copy link
Contributor

coderabbitai bot commented Oct 13, 2024

📝 Walkthrough

Walkthrough

The documentation for vacuum state management has been revised to indicate the deprecation of the state property, which is replaced by the new vacuum_state property. This transition aims to enhance state representation in Home Assistant Core 2024.11. The update includes a one-year deprecation notice for the old constants and provides an example for implementing the new property in custom classes. The states section has been reformatted to clarify enum values, and there is a push for migrating from VacuumEntity to StateVacuumEntity.

Changes

File(s) Change Summary
blog/2024-10-13-new-vacuum-state-property.md, docs/core/entity/vacuum.md Updated documentation to reflect the deprecation of state in favor of vacuum_state. Added example implementation for custom vacuum classes and reformatted state values to uppercase strings. Emphasized migration from VacuumEntity to StateVacuumEntity.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MyVacuumCleaner
    participant VacuumEntity
    participant VacuumEntityState

    User->>MyVacuumCleaner: Request vacuum state
    MyVacuumCleaner->>VacuumEntity: Get vacuum_state
    VacuumEntity->>VacuumEntityState: Return current state
    VacuumEntityState-->>MyVacuumCleaner: Return state value
    MyVacuumCleaner-->>User: Provide vacuum state
Loading

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 (4)
blog/2024-10-13-new-vacuum-state-property.md (2)

9-13: Minor grammatical correction needed.

Add a comma after "enum" on line 10 for better readability. Consider rewording the second sentence for clarity:

-As of Home Assistant Core 2024.11, the constants used to return state in `StateVacuumEntity` are deprecated and replaced by the `VacuumEntityState` enum.
+As of Home Assistant Core 2024.11, the constants used to return state in `StateVacuumEntity` are deprecated and replaced by the `VacuumEntityState` enum.
-Also with this change, integrations should set the `vacuum_state` property instead of directly setting the `state` property.
+With this change, integrations should now set the `vacuum_state` property instead of directly setting the `state` property.

The deprecation notice is clear and helpful for integration authors.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~10-~10: Possible missing comma found.
Context: ...laced by the VacuumEntityState enum. Also with this change, integrations should s...

(AI_HYDRA_LEO_MISSING_COMMA)


15-31: Code example is clear and accurate.

The example effectively demonstrates the new usage of VacuumEntityState enum and the implementation of the vacuum_state property. To enhance clarity for readers, consider adding a brief note about the StateVacuumEntity class:

+# StateVacuumEntity is a base class for vacuum entities that use predefined states
 class MyVacuumCleaner(StateVacuumEntity):
     """My vacuum cleaner."""

This addition would provide context for readers who might be unfamiliar with the class hierarchy.

docs/core/entity/vacuum.md (2)

25-25: Enhance the description of the vacuum_state property.

The introduction of the vacuum_state property aligns with the PR objectives. However, the description could be more informative.

Consider expanding the description to provide more context:

-| vacuum_state | VacuumEntityState | **Required** | Return one of the states listed in the states section.
+| vacuum_state | VacuumEntityState | **Required** | Return the current state of the vacuum. This property replaces the deprecated `state` property and uses the `VacuumEntityState` enum for more structured state representation.

29-38: Add deprecation notice and migration guidance for state constants.

The updated States section correctly reflects the new VacuumEntityState enum. However, it's important to provide information about the deprecation of the old constants and guidance for migration.

Consider adding the following information before the table:

:::warning Deprecation Notice
The old state constants (e.g., `STATE_CLEANING`, `STATE_DOCKED`) are deprecated and will be removed in Home Assistant Core 2024.11. Please update your custom components to use the new `VacuumEntityState` enum values.
:::

Example of migrating from old constants to the new enum:

```python
from homeassistant.components.vacuum import (
    StateVacuumEntity,
    VacuumEntityState
)

class MyVacuum(StateVacuumEntity):
    @property
    def vacuum_state(self) -> VacuumEntityState:
        if self._is_cleaning:
            return VacuumEntityState.CLEANING
        elif self._is_docked:
            return VacuumEntityState.DOCKED
        # ... other states ...

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**

<details>
<summary>📥 Commits</summary>

Files that changed from the base of the PR and between 570a91bcd2430ec2064bd47b931085c66cf5c31b and 98a51652ce85058b041daeb846f57e7700f85dd7.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* blog/2024-10-13-new-vacuum-state-property.md (1 hunks)
* docs/core/entity/vacuum.md (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>



<details>
<summary>📓 Path-based instructions (1)</summary><blockquote>

<details>
<summary>blog/2024-10-13-new-vacuum-state-property.md (6)</summary>

Pattern `*/**(html|markdown|md)`: - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.
- Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
- In step-by-step instructions, front the location phrase in the instructional sentence.
- In step-by-step instructions, front the 'goal' in the instructional sentence.
- In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
- do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'

---

Pattern `*/**(html|markdown|md)`: - Use bold to mark UI strings.
- If "" are used to mark UI strings, replace them by bold.

---

Pattern `*/**(html|markdown|md)`: - Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"

---

Pattern `*/**(html|markdown|md)`: - Use sentence-style capitalization also in headings.

---

Pattern `*/**(html|markdown|md)`: do not comment on HTML used for icons

---

Pattern `*/**(html|markdown|md)`: Avoid flagging inline HTML for embedding videos in future reviews for this repository.

</details>

</blockquote></details>

<details>
<summary>🪛 LanguageTool</summary><blockquote>

<details>
<summary>blog/2024-10-13-new-vacuum-state-property.md</summary><blockquote>

[uncategorized] ~10-~10: Possible missing comma found.
Context: ...laced by the `VacuumEntityState` enum.  Also with this change, integrations should s...

(AI_HYDRA_LEO_MISSING_COMMA)

</blockquote></details>

</blockquote></details>

</details>

<details>
<summary>🔇 Additional comments (5)</summary><blockquote>

<details>
<summary>blog/2024-10-13-new-vacuum-state-property.md (3)</summary><blockquote>

`1-7`: **Front matter looks good.**

The metadata is well-structured and provides comprehensive author information.

---

`33-33`: **Documentation link is correct and helpful.**

The link to additional vacuum documentation is properly formatted and provides a valuable resource for readers seeking more detailed information.

---

`1-33`: **Overall, excellent blog post on vacuum state property changes.**

The blog post effectively communicates the important changes to vacuum state management in Home Assistant Core 2024.11. It provides clear information about deprecation, introduces the new `VacuumEntityState` enum, and demonstrates its usage with a helpful code example. The content is well-structured and informative, making it valuable for integration authors and users alike.

The minor suggestions provided in the previous comments will further enhance the clarity and readability of this already strong documentation.

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 LanguageTool</summary><blockquote>

[uncategorized] ~10-~10: Possible missing comma found.
Context: ...laced by the `VacuumEntityState` enum.  Also with this change, integrations should s...

(AI_HYDRA_LEO_MISSING_COMMA)

</blockquote></details>

</details>

</blockquote></details>
<details>
<summary>docs/core/entity/vacuum.md (2)</summary><blockquote>

Line range hint `1-95`: **Summary of changes and next steps**

The documentation for the Vacuum entity has been updated to reflect the new `vacuum_state` property and the `VacuumEntityState` enum. These changes align with the PR objectives and enhance the state representation for vacuum entities.

Next steps:
1. Implement the suggested improvements to the property description and state section.
2. Add the deprecation notice and migration guidance for the old state constants.
3. Review the unchanged sections (Supported features and Methods) to ensure consistency with the new state representation.
4. Run the provided verification script to check for potential inconsistencies in the core code.

Once these steps are completed, the documentation will provide a comprehensive and up-to-date guide for implementing and using the Vacuum entity in Home Assistant.

---

Line range hint `40-95`: **Review unchanged sections for potential updates.**

While the Supported features and Methods sections remain unchanged, it might be beneficial to review them for consistency with the new state representation.

Please verify if any updates are needed in these sections, particularly:

1. In the Supported features section, check if the `VacuumEntityFeature.STATE` flag is still relevant or if it needs to be updated.
2. In the Methods section, confirm if any new methods need to be added or if existing methods need to be updated to work with the new `vacuum_state` property.

To assist with this verification, you can run the following script:

</blockquote></details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

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.

1 participant