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

fix: ws size #68

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open

fix: ws size #68

wants to merge 3 commits into from

Conversation

mikejgray
Copy link
Collaborator

@mikejgray mikejgray commented Feb 7, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a configurable WebSocket message size option, allowing improved control over connectivity.
    • Added a "Troubleshooting" section in the documentation to assist users with WebSocket API limitations.
  • Refactor

    • Streamlined configuration handling to automatically adjust display settings for enhanced interaction with the Home Assistant integration.
  • Documentation

    • Updated notes regarding the future of the plugin, indicating it will be merged with its companion skill and archived.

Copy link

coderabbitai bot commented Feb 7, 2025

Walkthrough

This pull request modifies the configuration and initialization logic for Home Assistant connectivity. The HomeAssistantPlugin class no longer passes the max_ws_message_size parameter during the instantiation of the HomeAssistantRESTConnector, and the init_configuration method signature has been updated. Additionally, the setup_configuration method has been enhanced to apply a configuration patch for the use_group_display setting. In the HomeAssistantWSConnector class, a new max_ws_message_size parameter with a default value is added to the constructor and passed to the HomeAssistantClient.

Changes

File(s) Change Summary
ovos_PHAL_plugin_home.../init.py - Removed the max_ws_message_size parameter from the HomeAssistantRESTConnector instantiation
- Updated init_configuration method signature (removed message parameter)
- Added a configuration patch to update the use_group_display setting
ovos_PHAL_plugin_home.../logic/connector.py - Added a new max_ws_message_size parameter (default=5242880) to the HomeAssistantWSConnector constructor
- Modified instantiation to pass the max_ws_message_size to HomeAssistantClient

Possibly related PRs

Suggested reviewers

  • JarbasAl
  • NeonDaniel

Poem

I'm a bunny coding through the night,
Hopping in the fields of change so bright,
REST sheds a parameter on its way,
WS gains one to join the play,
Configuration carrots crunch with delight,
ASCII trails and code so pure,
Hop along, PR changes endure!


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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8de77ce and e8c6e9f.

📒 Files selected for processing (2)
  • ovos_PHAL_plugin_homeassistant/__init__.py (0 hunks)
  • ovos_PHAL_plugin_homeassistant/logic/connector.py (1 hunks)
💤 Files with no reviewable changes (1)
  • ovos_PHAL_plugin_homeassistant/init.py
🔇 Additional comments (1)
ovos_PHAL_plugin_homeassistant/logic/connector.py (1)

311-311: LGTM! Good default value for max_ws_message_size.

The default value of 5MB (5242880 bytes) is a reasonable choice for WebSocket message size limit.

@mikejgray
Copy link
Collaborator Author

Confimed working in my ovos-mac setup

@@ -261,7 +261,6 @@ def init_configuration(self, message=None):
configuration_host,
configuration_api_key,
configuration_assist_only,
self.max_ws_message_size
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is only being dropped from the HomeAssistantRESTConnector, as it isn't used there

Comment on lines +314 to +317
self.host = self.host.replace("http", "ws", 1)
if self.host.startswith("https"):
self.host = self.host.replace("https", "wss", 1)
self._connection = HomeAssistantClient(url=self.host, token=self.api_key, max_ws_message_size=max_ws_message_size)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This condition functionally never happens, but at least the logic is now correct

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: 0

🧹 Nitpick comments (2)
README.md (2)

5-5: Clarify Plugin Roadmap Note
The note on line 5 has been updated to indicate that the plugin will be merged with its companion skill and later archived. Ensure that this terminology clearly conveys the intended roadmap to the users. For example, “archived” might be interpreted as deprecation; consider confirming that this aligns with the project’s communication strategy.


94-97: Enhance Troubleshooting Section Language
The new “Troubleshooting” section effectively highlights the limitations of the websocket API compared to the REST API. For improved clarity and a more formal tone, consider rephrasing “PRs welcome to work around this limitation” to a phrasing such as “Contributions to improve this limitation are welcome.” This small change can improve the professionalism of the documentation.

Proposed diff snippet:

-The websocket API does not expose entity information in the same way as the REST API, so some friendly names and aliases (especially for Assist) will not be available. PRs welcome to work around this limitation. Otherwise, we recommend using the REST API instead of the Websocket API.
+The websocket API does not expose entity information in the same way as the REST API, so some friendly names and aliases (especially for Assist) may not be available. Contributions to improve this limitation are welcome. Otherwise, we recommend using the REST API instead of the Websocket API.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 98b77a8 and 25fa27f.

📒 Files selected for processing (1)
  • README.md (2 hunks)

@mikejgray
Copy link
Collaborator Author

#69

Identified an interesting discrepancy during my testing, but it's out of scope for this PR. I updated the README to warn users.

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